From d47181a4a784203dad1c557d4cfcd667096a7358 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 22 Feb 2026 10:45:32 +0100 Subject: [PATCH] Silence cgroup warnings for non-existing PIDs When the kernel manages to reap a child process before we've moved it to its proper cgroup it will return ESRCH (No such process), we can safely ignore such errors for short-lived processes. Signed-off-by: Joachim Wiberg --- src/cgroup.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cgroup.c b/src/cgroup.c index 20289cf4..58e68875 100644 --- a/src/cgroup.c +++ b/src/cgroup.c @@ -190,7 +190,8 @@ int cgroup_move_pid(const char *group, const char *name, int pid, int delegate) } if (rc) { - warn("Failed moving pid %d to cgroup %s", pid, path); + if (errno != ESRCH) + warn("Failed moving pid %d to cgroup %s", pid, path); return -1; } } @@ -379,7 +380,8 @@ static int cgroup_leaf_init(const char *group, const char *name, int pid, const if (!strcmp(group, "root")) return fnwrite(str("%d", pid), FINIT_CGPATH "/cgroup.procs"); - if (cgroup_move_pid(group, name, pid, delegate)) + /* Error if error is not "No such process" */ + if (cgroup_move_pid(group, name, pid, delegate) && errno != ESRCH) err(1, "Failed moving pid %d to group %s/%s", pid, group, name); /* Set up inotify watch for cgroup cleanup */