From 57329832d0f93b3be3535355cc36edd4d676c69a Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 7 Mar 2022 15:47:31 +0100 Subject: [PATCH] initctl: skip cgroup in status output pid_cgruop() fails In some (error) cases the PID known to Finit may no longer exist, or may not have been added to a cgroup (yet). Handle this case by skipping the output of cgroup info in such conditions. Signed-off-by: Joachim Wiberg --- src/initctl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/initctl.c b/src/initctl.c index 6b11a7fa..2a0a437e 100644 --- a/src/initctl.c +++ b/src/initctl.c @@ -831,6 +831,8 @@ static int show_status(char *arg) char *group; group = pid_cgroup(svc->pid, grbuf, sizeof(grbuf)); + if (!group) + goto no_cgroup; /* ... or PID doesn't exist (anymore) */ snprintf(path, sizeof(path), "%s/%s", FINIT_CGPATH, group); cg = cg_conf(path); @@ -840,6 +842,7 @@ static int show_status(char *arg) cg->cg_mem.min, cg->cg_mem.max); show_cgroup_tree(group, " "); } + no_cgroup: printf("\n"); return do_log(svc->cmd);