- } else
- r = show_cgroup(SYSTEMD_CGROUP_CONTROLLER, "/", NULL, 0);
+ } else {
+ char *root = NULL;
+ const char *t = NULL;
+
+ if ((r = cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, 1, &root)) < 0)
+ t = "/";
+ else {
+ if (endswith(root, "/system"))
+ root[strlen(root)-7] = 0;
+
+ t = root[0] ? root : "/";
+ }
+
+ r = show_cgroup(SYSTEMD_CGROUP_CONTROLLER, t, NULL, 0);
+ free(root);
+ }