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 <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2026-02-22 20:36:34 +01:00
parent 8642007d0e
commit d47181a4a7
+4 -2
View File
@@ -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 */