diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-09-03 16:59:14 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-09-03 16:59:14 -0600 |
commit | df78914cae2dc2e3da5170cf3f9c7b412aed3afa (patch) | |
tree | 9817dd885f6a11fe3b9bdd6d56eddfb15e7634ba /src/sd_daemon/lsb/exit-status.go | |
parent | a6c2e22de92f459a52b8151ccc7f7c562c954750 (diff) |
Use a defer/recover block to have the exit status on panic match LSB.
Diffstat (limited to 'src/sd_daemon/lsb/exit-status.go')
-rw-r--r-- | src/sd_daemon/lsb/exit-status.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/sd_daemon/lsb/exit-status.go b/src/sd_daemon/lsb/exit-status.go index ba5b68b..41eaafd 100644 --- a/src/sd_daemon/lsb/exit-status.go +++ b/src/sd_daemon/lsb/exit-status.go @@ -1,5 +1,10 @@ package lsb +import ( + "os" + "sd_daemon/logger" +) + /* systemd daemon(7) recommends using the exit codes defined in the * "LSB recomendations for SysV init scripts"[1]. * @@ -60,3 +65,10 @@ const ( EXIT_BUS_ENDPOINT uint8 = 236 EXIT_SMACK_PROCESS_LABEL uint8 = 237 ) + +func Recover() { + if r := recover(); r != nil { + logger.Err("panic: %v", r) + os.Exit(int(EXIT_FAILURE)) + } +} |