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 ( import (
"os" "os"
"os/exec"
"os/signal" "os/signal"
"syscall" "syscall"
@ -81,14 +82,20 @@ func execAction(context *cli.Context) {
} }
fatal(err) fatal(err)
} }
status, err := process.Wait() status, err := process.Wait()
if err != nil { if err != nil {
exitError, ok := err.(*exec.ExitError)
if ok {
status = exitError.ProcessState
} else {
tty.Close() tty.Close()
if created { if created {
container.Destroy() container.Destroy()
} }
fatal(err) fatal(err)
} }
}
if created { if created {
if err := container.Destroy(); err != nil { if err := container.Destroy(); err != nil {
tty.Close() tty.Close()

View File

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