X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fexit-status.c;h=8ed1a0e362a3109e8552103d743ba36d0b6ba07b;hb=260a2be45522f03ce8d8aca38e471d7b0882ff05;hp=4fed3c70a4f43391a4d9e4a83297e4a7088701f0;hpb=1afbdcb06b2333c1f5852c049bd5e73b729aa6f0;p=elogind.git diff --git a/src/exit-status.c b/src/exit-status.c index 4fed3c70a..8ed1a0e36 100644 --- a/src/exit-status.c +++ b/src/exit-status.c @@ -20,6 +20,7 @@ ***/ #include +#include #include "exit-status.h" @@ -115,6 +116,9 @@ const char* exit_status_to_string(ExitStatus status, ExitStatusLevel level) { case EXIT_PAM: return "PAM"; + + case EXIT_NETWORK: + return "NETWORK"; } } @@ -143,3 +147,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); +}