mirror of
https://github.com/systemd/systemd.git
synced 2025-03-19 22:50:17 +03:00
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:
parent
e104fb80f4
commit
fe37a784fc
@ -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,21 +195,28 @@ static int process(
|
||||
g->n_tasks_valid = true;
|
||||
|
||||
} else if (streq(controller, "pids") && arg_count == COUNT_PIDS) {
|
||||
_cleanup_free_ char *p = NULL, *v = NULL;
|
||||
|
||||
r = cg_get_path(controller, path, "pids.current", &p);
|
||||
if (r < 0)
|
||||
return r;
|
||||
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 = read_one_line_file(p, &v);
|
||||
if (r == -ENOENT)
|
||||
return 0;
|
||||
if (r < 0)
|
||||
return r;
|
||||
r = cg_get_path(controller, path, "pids.current", &p);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = safe_atou64(v, &g->n_tasks);
|
||||
if (r < 0)
|
||||
return r;
|
||||
r = read_one_line_file(p, &v);
|
||||
if (r == -ENOENT)
|
||||
return 0;
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = safe_atou64(v, &g->n_tasks);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (g->n_tasks > 0)
|
||||
g->n_tasks_valid = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user