Close stdin after data has been copied

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi 2015-12-17 13:42:02 -08:00
parent 5faf2bd102
commit ae5c752449
2 changed files with 6 additions and 1 deletions

View file

@ -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()

5
io.go
View file

@ -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)