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