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

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{}) {