summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2015-09-03 16:59:14 -0600
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-09-03 16:59:14 -0600
commita5bad9d6ec4ce526015403c9565efea58d2867ea (patch)
treed3cf4d0f9bd3387c1bffddd40725efef605c495f
parent031737d8d1ed8ada3a260e0bdd7c2a874008982d (diff)
Use a defer/recover block to have the exit status on panic match LSB.
-rw-r--r--sd_daemon/lsb/exit-status.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/sd_daemon/lsb/exit-status.go b/sd_daemon/lsb/exit-status.go
index ba5b68b..41eaafd 100644
--- a/sd_daemon/lsb/exit-status.go
+++ b/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))
+ }
+}