Make sure to close the pipe upon ctrl-d

Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <guillaume.charmes@docker.com> (github: creack)
This commit is contained in:
Guillaume J. Charmes 2014-02-20 18:10:30 -08:00 committed by Michael Crosby
parent 97738ffed3
commit 52fa4de610

View file

@ -99,7 +99,10 @@ func execCommand(container *libcontainer.Container, tty bool, args []string) (in
}
defer term.RestoreTerminal(os.Stdin.Fd(), state)
} else {
go io.Copy(inPipe, os.Stdin)
go func() {
defer inPipe.Close()
io.Copy(inPipe, os.Stdin)
}()
go io.Copy(os.Stdout, outPipe)
go io.Copy(os.Stderr, errPipe)
}
@ -109,6 +112,7 @@ func execCommand(container *libcontainer.Container, tty bool, args []string) (in
return -1, err
}
}
return command.ProcessState.Sys().(syscall.WaitStatus).ExitStatus(), nil
}