chiark / gitweb /
service: consider a process exiting with SIGTERM a clean exit
[elogind.git] / util.c
diff --git a/util.c b/util.c
index 95791f941d86975dbff743b26e01eda335559a9b..5e3654d1d1ff383d96ec5de86381e85ed8a41d37 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1910,6 +1910,23 @@ int make_stdio(int fd) {
         return 0;
 }
 
         return 0;
 }
 
+bool is_clean_exit(int code, int status) {
+
+        if (code == CLD_EXITED)
+                return status == 0;
+
+        /* If a daemon does not implement handlers for some of the
+         * signals that's not considered an unclean shutdown */
+        if (code == CLD_KILLED)
+                return
+                        status == SIGHUP ||
+                        status == SIGINT ||
+                        status == SIGTERM ||
+                        status == SIGPIPE;
+
+        return false;
+}
+
 static const char *const ioprio_class_table[] = {
         [IOPRIO_CLASS_NONE] = "none",
         [IOPRIO_CLASS_RT] = "realtime",
 static const char *const ioprio_class_table[] = {
         [IOPRIO_CLASS_NONE] = "none",
         [IOPRIO_CLASS_RT] = "realtime",