Skip to content

Commit d47181a

Browse files
committed
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>
1 parent 8642007 commit d47181a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/cgroup.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ int cgroup_move_pid(const char *group, const char *name, int pid, int delegate)
190190
}
191191

192192
if (rc) {
193-
warn("Failed moving pid %d to cgroup %s", pid, path);
193+
if (errno != ESRCH)
194+
warn("Failed moving pid %d to cgroup %s", pid, path);
194195
return -1;
195196
}
196197
}
@@ -379,7 +380,8 @@ static int cgroup_leaf_init(const char *group, const char *name, int pid, const
379380
if (!strcmp(group, "root"))
380381
return fnwrite(str("%d", pid), FINIT_CGPATH "/cgroup.procs");
381382

382-
if (cgroup_move_pid(group, name, pid, delegate))
383+
/* Error if error is not "No such process" */
384+
if (cgroup_move_pid(group, name, pid, delegate) && errno != ESRCH)
383385
err(1, "Failed moving pid %d to group %s/%s", pid, group, name);
384386

385387
/* Set up inotify watch for cgroup cleanup */

0 commit comments

Comments
 (0)