process-util: add simple wrapper around PR_SET_CHILD_SUBREAPER

Let's a simple helper that knows how to deal with PID == 1.
This commit is contained in:
Lennart Poettering
2023-06-23 10:05:16 +02:00
parent 2499d32022
commit 8c3fe1b5b5
6 changed files with 28 additions and 9 deletions
+3 -2
View File
@@ -5826,8 +5826,9 @@ static int run(int argc, char *argv[]) {
assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, SIGWINCH, SIGTERM, SIGINT, SIGRTMIN+18, -1) >= 0);
if (prctl(PR_SET_CHILD_SUBREAPER, 1, 0, 0, 0) < 0) {
r = log_error_errno(errno, "Failed to become subreaper: %m");
r = make_reaper_process(true);
if (r < 0) {
log_error_errno(r, "Failed to become subreaper: %m");
goto finish;
}