Avoid race when opening exec fifo
Avoid race when opening exec fifo

When starting a container with `runc start` or `runc run`, the stub
process (runc[2:INIT]) opens a fifo for writing. Its parent runc process
will open the same fifo for reading. In this way, they synchronize.

If the stub process exits at the wrong time, the parent runc process
will block forever.

This can happen when racing 2 runc operations against each other: `runc
run/start`, and `runc delete`. It could also happen for other reasons,
e.g. the kernel's OOM killer may select the stub process.

This commit resolves this race by racing the opening of the exec fifo
from the runc parent process against the stub process exiting. If the
stub process exits before we open the fifo, we return an error.

Another solution is to wait on the stub process. However, it seems it
would require more refactoring to avoid calling wait multiple times on
the same process, which is an error.

Signed-off-by: Craig Furman <82b4b6d2372fcea863d8fd21c02d40060d303650@pivotal.io>

adrianreber/runc,laijs/runc,xiaochenshen/runc,kolyshkin/runc,dqminh/runc,dqminh/runc,kolyshkin/runc,justincormack/runc,stefanberger/runc,opencontainers/runc,adrianreber/runc,crosbymichael/runc,rhatdan/runc,dqminh/runc,adrianreber/runc,stefanberger/runc,laijs/runc,cyphar/runc,mYmNeo/runc,justincormack/runc,wking/runc,cyphar/runc,estesp/runc,wking/runc,estesp/runc,xiaochenshen/runc,mikebrow/runc,stefanberger/runc,dqminh/runc,crosbymichael/runc,kolyshkin/runc,mYmNeo/runc,crosbymichael/runc,opencontainers/runc,laijs/runc,rhatdan/runc,cyphar/runc,mikebrow/runc,justincormack/runc,xiaochenshen/runc,wking/runc,kolyshkin/runc,mheon/runc,opencontainers/runc,mheon/runc,mikebrow/runc,opencontainers/runc,estesp/runc,rhatdan/runc,mheon/runc,mYmNeo/runc,rhatdan/runc