Merge pull request #400 from mrunalp/exit_cleanup

Exit related cleanup
This commit is contained in:
Alexander Morozov 2015-02-25 13:18:27 -08:00
commit f6593810da
2 changed files with 12 additions and 4 deletions

View File

@ -2,6 +2,7 @@ package main
import (
"os"
"os/exec"
"os/signal"
"syscall"
@ -81,13 +82,19 @@ func execAction(context *cli.Context) {
}
fatal(err)
}
status, err := process.Wait()
if err != nil {
tty.Close()
if created {
container.Destroy()
exitError, ok := err.(*exec.ExitError)
if ok {
status = exitError.ProcessState
} else {
tty.Close()
if created {
container.Destroy()
}
fatal(err)
}
fatal(err)
}
if created {
if err := container.Destroy(); err != nil {

View File

@ -50,6 +50,7 @@ func fatal(err error) {
os.Exit(1)
}
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
func fatalf(t string, v ...interface{}) {