Skip to content

Commit 89c15bf

Browse files
committed
Fix exit handler for successful exits
1 parent e4534ca commit 89c15bf

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

gaper.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,18 +145,16 @@ func restart(builder Builder, runner Runner) error {
145145
}
146146

147147
func handleProgramExit(builder Builder, runner Runner, err error, noRestartOn string) error {
148-
exiterr, ok := err.(*exec.ExitError)
149-
if !ok {
150-
return fmt.Errorf("couldn't handle program crash restart: %v", err)
151-
}
148+
var exitStatus int
149+
if exiterr, ok := err.(*exec.ExitError); ok {
150+
status, oks := exiterr.Sys().(syscall.WaitStatus)
151+
if !oks {
152+
return fmt.Errorf("couldn't resolve exit status: %v", err)
153+
}
152154

153-
status, oks := exiterr.Sys().(syscall.WaitStatus)
154-
if !oks {
155-
return fmt.Errorf("couldn't resolve exit status: %v", err)
155+
exitStatus = status.ExitStatus()
156156
}
157157

158-
exitStatus := status.ExitStatus()
159-
160158
// if "error", an exit code of 0 will still restart.
161159
if noRestartOn == "error" && exitStatus == exitStatusError {
162160
return nil

0 commit comments

Comments
 (0)