From: Mike Yuan Date: Mon, 11 Nov 2024 18:38:36 +0000 (+0100) Subject: process-util: refuse FORK_DETACH + FORK_DEATHSIG_* X-Git-Tag: v257-rc2~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c8590ad60d17b8354d6c8e3f79b1de50abac919a;p=thirdparty%2Fsystemd.git process-util: refuse FORK_DETACH + FORK_DEATHSIG_* There's no synchoronization between the intermediate process and the double-forked child, and the semantics are not useful. Refuse such combination. --- diff --git a/src/basic/process-util.c b/src/basic/process-util.c index 9c159b46055..adc576a84f8 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -1460,8 +1460,8 @@ int safe_fork_full( bool block_signals = false, block_all = false, intermediary = false; int prio, r; - assert(!FLAGS_SET(flags, FORK_DETACH) || !ret_pid); - assert(!FLAGS_SET(flags, FORK_DETACH|FORK_WAIT)); + assert(!FLAGS_SET(flags, FORK_DETACH) || + (!ret_pid && (flags & (FORK_WAIT|FORK_DEATHSIG_SIGTERM|FORK_DEATHSIG_SIGINT|FORK_DEATHSIG_SIGKILL)) == 0)); /* A wrapper around fork(), that does a couple of important initializations in addition to mere forking. Always * returns the child's PID in *ret_pid. Returns == 0 in the child, and > 0 in the parent. */