]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
async: use FORK_DETACH for asynchronous syncs
authorLennart Poettering <lennart@poettering.net>
Thu, 22 Jun 2023 13:11:52 +0000 (15:11 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 23 Jun 2023 08:05:16 +0000 (10:05 +0200)
To get proper "fire-and-forget" feeling we really want to make sure
noone has to reap the forked off process.

src/shared/async.c

index cb5e179cdfafed85298c8578dacd43083d56494c..b7ecb9c4b76d83bcdd947207b2120e9d99402568 100644 (file)
@@ -22,7 +22,7 @@ int asynchronous_sync(pid_t *ret_pid) {
          * original process ever, and a thread would do that as the process can't exit with threads hanging in blocking
          * syscalls. */
 
-        r = safe_fork("(sd-sync)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS, ret_pid);
+        r = safe_fork("(sd-sync)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|(ret_pid ? 0 : FORK_DETACH), ret_pid);
         if (r < 0)
                 return r;
         if (r == 0) {