summaryrefslogtreecommitdiffstats
path: root/src/cgtop
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-02-09 16:58:35 +0100
committerLennart Poettering <lennart@poettering.net>2018-02-09 16:58:35 +0100
commita7e6de218b255a14229953a1f6656915ece9db1b (patch)
treef63071a24ce27af2b2925ead5a343467cbaa6225 /src/cgtop
parentcgtop: add "-1" as shortcut for "--iterations=1" (diff)
downloadsystemd-a7e6de218b255a14229953a1f6656915ece9db1b.tar.xz
systemd-a7e6de218b255a14229953a1f6656915ece9db1b.zip
cgtop: add helper for checking if we are operating on the root cgroup
Diffstat (limited to 'src/cgtop')
-rw-r--r--src/cgtop/cgtop.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c
index 1575cd51ff..229aadd269 100644
--- a/src/cgtop/cgtop.c
+++ b/src/cgtop/cgtop.c
@@ -125,6 +125,10 @@ static const char *maybe_format_bytes(char *buf, size_t l, bool is_valid, uint64
return format_bytes(buf, l, t);
}
+static bool is_root_cgroup(const char *path) {
+ return isempty(path) || path_equal(path, "/");
+}
+
static int process(
const char *controller,
const char *path,
@@ -196,7 +200,7 @@ static int process(
} else if (streq(controller, "pids") && arg_count == COUNT_PIDS) {
- if (isempty(path) || path_equal(path, "/")) {
+ if (is_root_cgroup(path)) {
r = procfs_tasks_get_current(&g->n_tasks);
if (r < 0)
return r;