]> err.no Git - systemd/commitdiff
service: brutally slaughter processes that are running in the cgroup when we enter...
authorLennart Poettering <lennart@poettering.net>
Wed, 11 Jan 2012 00:51:32 +0000 (01:51 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 11 Jan 2012 01:52:34 +0000 (02:52 +0100)
src/cgroup.c
src/service.c

index 4bbb54fd7e41a17f96ea8f3b651cc43aa8e5f089..9680cd6d2a18886c6e671b7b10c96fd8f3fb1b5b 100644 (file)
@@ -197,6 +197,9 @@ int cgroup_bonding_kill_list(CGroupBonding *first, int sig, bool sigcont, Set *s
         Set *allocated_set = NULL;
         int ret = -EAGAIN, r;
 
+        if (!first)
+                return 0;
+
         if (!s)
                 if (!(s = allocated_set = set_new(trivial_hash_func, trivial_compare_func)))
                         return -ENOMEM;
index 0110c9f12f37fcbe70aab5b4534caaa65e1d5785..113be34ad0b3ccbcb4ca2870620d77991249d183 100644 (file)
@@ -2021,6 +2021,11 @@ static void service_enter_start(Service *s) {
         else
                 service_unwatch_main_pid(s);
 
+        /* We want to ensure that nobody leaks processes from
+         * START_PRE here, so let's go on a killing spree, People
+         * should not spawn long running processes from START_PRE. */
+        cgroup_bonding_kill_list(s->meta.cgroup_bondings, SIGKILL, true, NULL);
+
         if (s->type == SERVICE_FORKING) {
                 s->control_command_id = SERVICE_EXEC_START;
                 c = s->control_command = s->exec_command[SERVICE_EXEC_START];
@@ -2090,6 +2095,11 @@ static void service_enter_start_pre(Service *s) {
         service_unwatch_control_pid(s);
 
         if ((s->control_command = s->exec_command[SERVICE_EXEC_START_PRE])) {
+
+                /* Before we start anything, let's clear up what might
+                 * be left from previous runs. */
+                cgroup_bonding_kill_list(s->meta.cgroup_bondings, SIGKILL, true, NULL);
+
                 s->control_command_id = SERVICE_EXEC_START_PRE;
 
                 if ((r = service_spawn(s,