summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-04-21 02:17:01 +0200
committerLennart Poettering <lennart@poettering.net>2015-04-21 02:17:01 +0200
commit4940c0b0b621c0d5a4a3c1f3bc281ecba6151c58 (patch)
tree048feca72ac5e8ed45cbcfac7e4f3c0cb995e51f /src/core
parent98b32556701f2cc80495488b5d724577637540f6 (diff)
service: make kill operation mapping explicit
Diffstat (limited to 'src/core')
-rw-r--r--src/core/service.c22
-rw-r--r--src/core/unit.h2
2 files changed, 22 insertions, 2 deletions
diff --git a/src/core/service.c b/src/core/service.c
index fa818fc871..3b241fd0a4 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -1367,6 +1367,25 @@ fail:
service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_RESOURCES);
}
+static int state_to_kill_operation(ServiceState state) {
+ switch (state) {
+
+ case SERVICE_STOP_SIGABRT:
+ return KILL_ABORT;
+
+ case SERVICE_STOP_SIGTERM:
+ case SERVICE_FINAL_SIGTERM:
+ return KILL_TERMINATE;
+
+ case SERVICE_STOP_SIGKILL:
+ case SERVICE_FINAL_SIGKILL:
+ return KILL_KILL;
+
+ default:
+ return _KILL_OPERATION_INVALID;
+ }
+}
+
static void service_enter_signal(Service *s, ServiceState state, ServiceResult f) {
int r;
@@ -1380,8 +1399,7 @@ static void service_enter_signal(Service *s, ServiceState state, ServiceResult f
r = unit_kill_context(
UNIT(s),
&s->kill_context,
- (state != SERVICE_STOP_SIGTERM && state != SERVICE_FINAL_SIGTERM && state != SERVICE_STOP_SIGABRT) ?
- KILL_KILL : (state == SERVICE_STOP_SIGABRT ? KILL_ABORT : KILL_TERMINATE),
+ state_to_kill_operation(state),
s->main_pid,
s->control_pid,
s->main_pid_alien);
diff --git a/src/core/unit.h b/src/core/unit.h
index 11242c2a00..260dc451c7 100644
--- a/src/core/unit.h
+++ b/src/core/unit.h
@@ -52,6 +52,8 @@ typedef enum KillOperation {
KILL_TERMINATE,
KILL_KILL,
KILL_ABORT,
+ _KILL_OPERATION_MAX,
+ _KILL_OPERATION_INVALID = -1
} KillOperation;
static inline bool UNIT_IS_ACTIVE_OR_RELOADING(UnitActiveState t) {