From ae5c752449f18e32824b3a50b8c7e7305c85d5c0 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Thu, 17 Dec 2015 13:42:02 -0800 Subject: [PATCH] Close stdin after data has been copied Signed-off-by: Tonis Tiigi --- ctr/container.go | 2 ++ io.go | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ctr/container.go b/ctr/container.go index a1de897..8b0758f 100644 --- a/ctr/container.go +++ b/ctr/container.go @@ -131,6 +131,7 @@ var StartCommand = cli.Command{ if state != nil { term.RestoreTerminal(os.Stdin.Fd(), state) } + stdin.Close() }() for { e, err := events.Recv() @@ -335,6 +336,7 @@ var ExecCommand = cli.Command{ if state != nil { term.RestoreTerminal(os.Stdin.Fd(), state) } + stdin.Close() }() for { e, err := events.Recv() diff --git a/io.go b/io.go index 8162807..e75f194 100644 --- a/io.go +++ b/io.go @@ -25,7 +25,10 @@ func newCopier(i *ioConfig) (*copier, error) { return nil, err } l.closers = append(l.closers, f) - go io.Copy(i.Stdin, f) + go func() { + io.Copy(i.Stdin, f) + i.Stdin.Close() + }() } if i.StdoutPath != "" { f, err := os.OpenFile(i.StdoutPath, os.O_RDWR, 0)