From: Lennart Poettering Date: Thu, 22 Jun 2023 13:11:52 +0000 (+0200) Subject: async: use FORK_DETACH for asynchronous syncs X-Git-Tag: v254-rc1~133^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=530f6ada2ef253d726b91e5f8e2f6b204f69aea5;p=thirdparty%2Fsystemd.git async: use FORK_DETACH for asynchronous syncs To get proper "fire-and-forget" feeling we really want to make sure noone has to reap the forked off process. --- diff --git a/src/shared/async.c b/src/shared/async.c index cb5e179cdfa..b7ecb9c4b76 100644 --- a/src/shared/async.c +++ b/src/shared/async.c @@ -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) {