cgtop: make sure we can show a tasks number for the root cgroup too

Let's also use our new API in cgtop so that we can finally show a usable
tasks count for the root cgroup too. Yay!
This commit is contained in:
Lennart Poettering 2018-01-17 19:01:44 +01:00
parent e104fb80f4
commit fe37a784fc
1 changed files with 20 additions and 12 deletions

View File

@ -40,6 +40,7 @@
#include "parse-util.h"
#include "path-util.h"
#include "process-util.h"
#include "procfs-util.h"
#include "stdio-util.h"
#include "strv.h"
#include "terminal-util.h"
@ -194,6 +195,12 @@ static int process(
g->n_tasks_valid = true;
} else if (streq(controller, "pids") && arg_count == COUNT_PIDS) {
if (isempty(path) || path_equal(path, "/")) {
r = procfs_tasks_get_current(&g->n_tasks);
if (r < 0)
return r;
} else {
_cleanup_free_ char *p = NULL, *v = NULL;
r = cg_get_path(controller, path, "pids.current", &p);
@ -209,6 +216,7 @@ static int process(
r = safe_atou64(v, &g->n_tasks);
if (r < 0)
return r;
}
if (g->n_tasks > 0)
g->n_tasks_valid = true;