Merge pull request #66 from coolljt0725/fix_termimal

Fix container exit not restore terminal and close stdin
This commit is contained in:
Michael Crosby 2016-01-11 10:22:22 -08:00
commit a4576937f9
1 changed files with 7 additions and 2 deletions

View File

@ -126,19 +126,24 @@ var StartCommand = cli.Command{
fatal(err.Error(), 1)
}
if context.Bool("attach") {
go func() {
io.Copy(stdin, os.Stdin)
restoreAndCloseStdin := func() {
if state != nil {
term.RestoreTerminal(os.Stdin.Fd(), state)
}
stdin.Close()
}
go func() {
io.Copy(stdin, os.Stdin)
restoreAndCloseStdin()
}()
for {
e, err := events.Recv()
if err != nil {
restoreAndCloseStdin()
fatal(err.Error(), 1)
}
if e.Id == id && e.Type == "exit" {
restoreAndCloseStdin()
os.Exit(int(e.Status))
}
}