From 1f16b4a6c496288aa62dc2ac973f88ca6c801b5d Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 14 Mar 2011 23:40:41 +0100 Subject: [PATCH] cgls: by default start with group of PID 1 --- src/cgls.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/cgls.c b/src/cgls.c index 93617ddc..6f083015 100644 --- a/src/cgls.c +++ b/src/cgls.c @@ -106,8 +106,18 @@ int main(int argc, char *argv[]) { if (path_startswith(p, "/sys/fs/cgroup")) { printf("Working Directory %s:\n", p); r = show_cgroup_by_path(p, NULL, 0); - } 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 + t = root; + + r = show_cgroup(SYSTEMD_CGROUP_CONTROLLER, t, NULL, 0); + free(root); + } free(p); } -- 2.39.5