summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-11-05 22:14:52 +0100
committerLennart Poettering <lennart@poettering.net>2013-11-06 02:12:21 +0100
commit15c60e99a974782351ca8a5ed438dc3729eb5fe7 (patch)
treed12c19004b47ae6b8d9e4912c30e09f98cf07fe0 /src/core
parent2270309471213a3c960543e523130627e9cb10e2 (diff)
cgroup: run PID 1 in the root cgroup
This way cleaning up the cgroup tree on shutdown is a lot easier since we are in the root dir. Also PID 1 was previously artificially placed in system.slice, even though our rule actually was not to have processes in slices. The root slice otoh is magic anyway, so having PID 1 in there sounds less surprising. Of course, this means that PID is scheduled against the three top-level slices.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/cgroup.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index f0a97e6818..f2a99c76b7 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -589,8 +589,8 @@ pid_t unit_search_main_pid(Unit *u) {
int manager_setup_cgroup(Manager *m) {
_cleanup_free_ char *path = NULL;
+ char *e;
int r;
- char *e, *a;
assert(m);
@@ -610,9 +610,13 @@ int manager_setup_cgroup(Manager *m) {
return r;
}
- /* Already in /system.slice? If so, let's cut this off again */
+ /* LEGACY: Already in /system.slice? If so, let's cut this
+ * off. This is to support live upgrades from older systemd
+ * versions where PID 1 was moved there. */
if (m->running_as == SYSTEMD_SYSTEM) {
e = endswith(m->cgroup_root, "/" SPECIAL_SYSTEM_SLICE);
+ if (!e)
+ e = endswith(m->cgroup_root, "/system");
if (e)
*e = 0;
}
@@ -643,12 +647,8 @@ int manager_setup_cgroup(Manager *m) {
log_debug("Release agent already installed.");
}
- /* 4. Realize the system slice and put us in there */
- if (m->running_as == SYSTEMD_SYSTEM) {
- a = strappenda(m->cgroup_root, "/" SPECIAL_SYSTEM_SLICE);
- r = cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, a, 0);
- } else
- r = cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_root, 0);
+ /* 4. Make sure we are in the root cgroup */
+ r = cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_root, 0);
if (r < 0) {
log_error("Failed to create root cgroup hierarchy: %s", strerror(-r));
return r;