summaryrefslogtreecommitdiff
path: root/src/shared/exit-status.c
diff options
context:
space:
mode:
authorLukas Nykryn <lnykryn@redhat.com>2012-08-13 13:58:01 +0200
committerLennart Poettering <lennart@poettering.net>2012-08-14 14:46:03 +0200
commit96342de68d0d6de71a062d984dafd2a0905ed9fe (patch)
treeadbeb686c6c3c2bfd5a1c8768555575acb4850a2 /src/shared/exit-status.c
parentd98cc1f29fbf31ccc500d6e20c29b636b9af7e0f (diff)
service: add options RestartPreventExitStatus and SuccessExitStatus
In some cases, like wrong configuration, restarting after error does not help, so administrator can specify statuses by RestartPreventExitStatus which will not cause restart of a service. Sometimes you have non-standart exit status, so this can be specified by SuccessfulExitStatus.
Diffstat (limited to 'src/shared/exit-status.c')
-rw-r--r--src/shared/exit-status.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/shared/exit-status.c b/src/shared/exit-status.c
index 0dc82b2e13..45131f2b2a 100644
--- a/src/shared/exit-status.c
+++ b/src/shared/exit-status.c
@@ -23,6 +23,8 @@
#include <sys/wait.h>
#include "exit-status.h"
+#include "set.h"
+#include "macro.h"
const char* exit_status_to_string(ExitStatus status, ExitStatusLevel level) {
@@ -158,10 +160,12 @@ const char* exit_status_to_string(ExitStatus status, ExitStatusLevel level) {
}
-bool is_clean_exit(int code, int status) {
+bool is_clean_exit(int code, int status, ExitStatusSet *success_status) {
if (code == CLD_EXITED)
- return status == 0;
+ return status == 0 ||
+ (success_status &&
+ set_contains(success_status->code, INT_TO_PTR(status)));
/* If a daemon does not implement handlers for some of the
* signals that's not considered an unclean shutdown */
@@ -170,14 +174,16 @@ bool is_clean_exit(int code, int status) {
status == SIGHUP ||
status == SIGINT ||
status == SIGTERM ||
- status == SIGPIPE;
+ status == SIGPIPE ||
+ (success_status &&
+ set_contains(success_status->signal, INT_TO_PTR(status)));
return false;
}
-bool is_clean_exit_lsb(int code, int status) {
+bool is_clean_exit_lsb(int code, int status, ExitStatusSet *success_status) {
- if (is_clean_exit(code, status))
+ if (is_clean_exit(code, status, success_status))
return true;
return