Fix exit handler for successful exits

This commit is contained in:
Max Claus Nunes 2018-06-24 20:47:46 -03:00
parent e4534caa82
commit 89c15bf15c
1 changed files with 7 additions and 9 deletions

View File

@ -145,17 +145,15 @@ func restart(builder Builder, runner Runner) error {
}
func handleProgramExit(builder Builder, runner Runner, err error, noRestartOn string) error {
exiterr, ok := err.(*exec.ExitError)
if !ok {
return fmt.Errorf("couldn't handle program crash restart: %v", err)
}
var exitStatus int
if exiterr, ok := err.(*exec.ExitError); ok {
status, oks := exiterr.Sys().(syscall.WaitStatus)
if !oks {
return fmt.Errorf("couldn't resolve exit status: %v", err)
}
exitStatus := status.ExitStatus()
exitStatus = status.ExitStatus()
}
// if "error", an exit code of 0 will still restart.
if noRestartOn == "error" && exitStatus == exitStatusError {