Don't block on STDIN open

This was found testing other runtime shims that are faster than runc(no
containerization).  This is a race that can cause the shim to block
forever.  It's not an issue for out/err because we open both sides of
the pipe, but for stdin, it expects the client to have it opened.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2018-08-15 16:40:05 -04:00
parent 6b00aaaf20
commit bc1ff51411
4 changed files with 5 additions and 12 deletions

View File

@@ -112,7 +112,7 @@ func copyPipes(ctx context.Context, rio runc.IO, stdin, stdout, stderr string, w
rio.Stdin().Close()
return nil
}
f, err := fifo.OpenFifo(ctx, stdin, syscall.O_RDONLY, 0)
f, err := fifo.OpenFifo(ctx, stdin, syscall.O_RDONLY|syscall.O_NONBLOCK, 0)
if err != nil {
return fmt.Errorf("containerd-shim: opening %s failed: %s", stdin, err)
}