chiark / gitweb /
Classify processes from sessions into cgroups
[elogind.git] / src / shared / exit-status.c
index 942ac86128be814a384be4801d1dc3c77df938b9..c09efdd2cb79c1643aed2c8042e3f90f361d8f07 100644 (file)
@@ -20,7 +20,6 @@
 ***/
 
 #include <stdlib.h>
-#include <sys/wait.h>
 
 #include "exit-status.h"
 #include "set.h"
@@ -148,6 +147,9 @@ const char* exit_status_to_string(ExitStatus status, ExitStatusLevel level) {
 
                 case EXIT_MAKE_STARTER:
                         return "MAKE_STARTER";
+
+                case EXIT_BUS_ENDPOINT:
+                        return "BUS_ENDPOINT";
                 }
         }
 
@@ -164,7 +166,7 @@ const char* exit_status_to_string(ExitStatus status, ExitStatusLevel level) {
                         return "NOPERMISSION";
 
                 case EXIT_NOTINSTALLED:
-                        return "NOTINSSTALLED";
+                        return "NOTINSTALLED";
 
                 case EXIT_NOTCONFIGURED:
                         return "NOTCONFIGURED";
@@ -216,3 +218,24 @@ void exit_status_set_free(ExitStatusSet *x) {
         set_free(x->signal);
         x->status = x->signal = NULL;
 }
+
+bool exit_status_set_is_empty(ExitStatusSet *x) {
+        if (!x)
+                return true;
+
+        return set_isempty(x->status) && set_isempty(x->signal);
+}
+
+bool exit_status_set_test(ExitStatusSet *x, int code, int status) {
+
+        if (exit_status_set_is_empty(x))
+                return false;
+
+        if (code == CLD_EXITED && set_contains(x->status, INT_TO_PTR(status)))
+                return true;
+
+        if (IN_SET(code, CLD_KILLED, CLD_DUMPED) && set_contains(x->signal, INT_TO_PTR(status)))
+                return true;
+
+        return false;
+}