chiark / gitweb /
cgroup: Handle error when destroying cgroup
authorRoss Lagerwall <rosslagerwall@gmail.com>
Sat, 29 Nov 2014 15:27:14 +0000 (15:27 +0000)
committerLennart Poettering <lennart@poettering.net>
Tue, 9 Dec 2014 01:28:09 +0000 (02:28 +0100)
If a cgroup fails to be destroyed (most likely because there are still
processes running as part of a service after the main pid exits), don't
free and remove the cgroup unit from the manager.  This fixes a
regression introduced by the cgroup rework in v205 where systemd would
forget about processes still running after the unit becomes inactive.
(This can happen when the main pid exits and KillMode=process or none).

src/core/cgroup.c

index 70fc925b4dfedde9bcfde694acf600f545af1b76..af048354e1fa71d23fde70783150183bf45c69f3 100644 (file)
@@ -791,8 +791,10 @@ void unit_destroy_cgroup(Unit *u) {
                 return;
 
         r = cg_trim_everywhere(u->manager->cgroup_supported, u->cgroup_path, !unit_has_name(u, SPECIAL_ROOT_SLICE));
                 return;
 
         r = cg_trim_everywhere(u->manager->cgroup_supported, u->cgroup_path, !unit_has_name(u, SPECIAL_ROOT_SLICE));
-        if (r < 0)
+        if (r < 0) {
                 log_debug_errno(r, "Failed to destroy cgroup %s: %m", u->cgroup_path);
                 log_debug_errno(r, "Failed to destroy cgroup %s: %m", u->cgroup_path);
+                return;
+        }
 
         hashmap_remove(u->manager->cgroup_unit, u->cgroup_path);
 
 
         hashmap_remove(u->manager->cgroup_unit, u->cgroup_path);