chiark / gitweb /
journal: vacuum corrupted files, too
[elogind.git] / src / exit-status.c
index 4fed3c70a4f43391a4d9e4a83297e4a7088701f0..ab8907d32c1c2f9bb9aaa5913a2af8a8a75db35d 100644 (file)
@@ -20,6 +20,7 @@
 ***/
 
 #include <stdlib.h>
+#include <sys/wait.h>
 
 #include "exit-status.h"
 
@@ -115,6 +116,12 @@ const char* exit_status_to_string(ExitStatus status, ExitStatusLevel level) {
 
                 case EXIT_PAM:
                         return "PAM";
+
+                case EXIT_NETWORK:
+                        return "NETWORK";
+
+                case EXIT_NAMESPACE:
+                        return "NAMESPACE";
                 }
         }
 
@@ -143,3 +150,31 @@ const char* exit_status_to_string(ExitStatus status, ExitStatusLevel level) {
 
         return NULL;
 }
+
+
+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;
+}
+
+bool is_clean_exit_lsb(int code, int status) {
+
+        if (is_clean_exit(code, status))
+                return true;
+
+        return
+                code == CLD_EXITED &&
+                (status == EXIT_NOTINSTALLED || status == EXIT_NOTCONFIGURED);
+}