Skip to content

Commit

Permalink
Close stdin after copy returns
Browse files Browse the repository at this point in the history
Make sure we close stdin after the copy returns so that containers that
issue a CloseStdin exit and all the io is closed when the write side of
the fifo is closed.

Signed-off-by: Michael Crosby <[email protected]>
  • Loading branch information
crosbymichael committed May 3, 2017
1 parent d10daaf commit 731702b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion containerd-shim/process_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,15 @@ func (p *process) openIO() error {
if err != nil {
return fmt.Errorf("containerd-shim: opening %s failed: %s", p.state.Stdin, err)
}
ioClosers = append(ioClosers, i.Stdin, f)
p.ioCleanupFn = func() {
for _, c := range ioClosers {
c.Close()
}
}
go func() {
io.Copy(i.Stdin, f)
i.Stdin.Close()
f.Close()
}()

return nil
Expand Down

0 comments on commit 731702b

Please sign in to comment.