summaryrefslogtreecommitdiff
path: root/src/exit-status.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-01-20 18:22:03 +0100
committerLennart Poettering <lennart@poettering.net>2011-01-20 18:22:03 +0100
commit9a57c62944258c750d80bca4fe56de4dbab46d67 (patch)
tree7194ffec3e7e66b63a9e457b8a79be9c25daeafb /src/exit-status.c
parent0129173ab03994d21a21f9fc1f454faf62b97043 (diff)
systemctl: highlight failed processes in systemctl status
Diffstat (limited to 'src/exit-status.c')
-rw-r--r--src/exit-status.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/exit-status.c b/src/exit-status.c
index 4fed3c70a4..9b7c027b43 100644
--- a/src/exit-status.c
+++ b/src/exit-status.c
@@ -20,6 +20,7 @@
***/
#include <stdlib.h>
+#include <sys/wait.h>
#include "exit-status.h"
@@ -143,3 +144,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);
+}