summaryrefslogtreecommitdiff
path: root/src/basic/cgroup-util.c
diff options
context:
space:
mode:
authorDaniel Black <daniel@linux.ibm.com>2019-01-16 21:20:18 +1100
committerDaniel Black <daniel@linux.ibm.com>2019-01-29 15:35:59 +1100
commitc53d2d54bd29bd6f4c21705ae23425ade8c12167 (patch)
tree99a279fe88a0c143f3c707ef881e8920cc9f5a14 /src/basic/cgroup-util.c
parent61a38e02650b8e7f097cadaa40aab0847605a383 (diff)
downloadsystemd-c53d2d54bd29bd6f4c21705ae23425ade8c12167.tar.gz
service: make killmode=cgroup|mixed, SendSIGKILL=no services singletons
KillMode=mixed and control group are used to indicate that all process should be killed off. SendSIGKILL is used for services that require a clean shutdown. These are typically database service where a SigKilled process would result in a lengthy recovery and who's shutdown or startup time is quite variable (so Timeout settings aren't of use). Here we take these two factors and refuse to start a service if there are existing processes within a control group. Databases, while generally having some protection against multiple instances running, lets not stress the rigor of these. Also ExecStartPre parts of the service aren't as rigoriously written to protect against against multiple use. closes #8630
Diffstat (limited to 'src/basic/cgroup-util.c')
-rw-r--r--src/basic/cgroup-util.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c
index 8ce7ccb960..dcc0ffdf44 100644
--- a/src/basic/cgroup-util.c
+++ b/src/basic/cgroup-util.c
@@ -223,7 +223,7 @@ int cg_kill(
_cleanup_set_free_ Set *allocated_set = NULL;
bool done = false;
- int r, ret = 0;
+ int r, ret = 0, ret_log_kill = 0;
pid_t my_pid;
assert(sig >= 0);
@@ -267,7 +267,7 @@ int cg_kill(
continue;
if (log_kill)
- log_kill(pid, sig, userdata);
+ ret_log_kill = log_kill(pid, sig, userdata);
/* If we haven't killed this process yet, kill
* it */
@@ -278,8 +278,12 @@ int cg_kill(
if (flags & CGROUP_SIGCONT)
(void) kill(pid, SIGCONT);
- if (ret == 0)
- ret = 1;
+ if (ret == 0) {
+ if (log_kill)
+ ret = ret_log_kill;
+ else
+ ret = 1;
+ }
}
done = false;