Handle process natural death a bit better

This commit is contained in:
Ivar Gaitan
2015-03-05 23:59:51 +01:00
committed by Derek Parker
parent f39e134d1d
commit 8b04d877a0
6 changed files with 54 additions and 29 deletions

View File

@ -87,9 +87,14 @@ func Run(run bool, pid int, args []string) {
}
cmd := cmds.Find(cmdstr)
err = cmd(dbp, args...)
if err != nil {
fmt.Fprintf(os.Stderr, "Command failed: %s\n", err)
if err := cmd(dbp, args...); err != nil {
switch err.(type) {
case proctl.ProcessExitedError:
pe := err.(proctl.ProcessExitedError)
fmt.Fprintf(os.Stderr, "Process exited with status %d\n", pe.Status)
default:
fmt.Fprintf(os.Stderr, "Command failed: %s\n", err)
}
}
}
}