From: Luca Boccassi Date: Wed, 9 Aug 2023 13:02:34 +0000 (+0100) Subject: core: split manager's process killing on shutdown to separate helper X-Git-Tag: v255-rc1~745^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F28799%2Fhead;p=thirdparty%2Fsystemd.git core: split manager's process killing on shutdown to separate helper --- diff --git a/src/core/main.c b/src/core/main.c index 1fe93a2f554..e6932784d15 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1818,6 +1818,19 @@ static void filter_args( } } +static void finish_remaining_processes(ManagerObjective objective) { + assert(objective >= 0 && objective < _MANAGER_OBJECTIVE_MAX); + + /* Kill all remaining processes from the initrd, but don't wait for them, so that we can handle the + * SIGCHLD for them after deserializing. */ + if (IN_SET(objective, MANAGER_SWITCH_ROOT, MANAGER_SOFT_REBOOT)) + broadcast_signal(SIGTERM, /* wait_for_exit= */ false, /* send_sighup= */ true, arg_default_timeout_stop_usec); + + /* On soft reboot really make sure nothing is left */ + if (objective == MANAGER_SOFT_REBOOT) + broadcast_signal(SIGKILL, /* wait_for_exit= */ false, /* send_sighup= */ false, arg_default_timeout_stop_usec); +} + static int do_reexecute( ManagerObjective objective, int argc, @@ -1868,13 +1881,7 @@ static int do_reexecute( if (saved_rlimit_memlock->rlim_cur != RLIM_INFINITY) (void) setrlimit(RLIMIT_MEMLOCK, saved_rlimit_memlock); - /* Kill all remaining processes from the initrd, but don't wait for them, so that we can handle the - * SIGCHLD for them after deserializing. */ - if (IN_SET(objective, MANAGER_SWITCH_ROOT, MANAGER_SOFT_REBOOT)) - broadcast_signal(SIGTERM, /* wait_for_exit= */ false, /* send_sighup= */ true, arg_default_timeout_stop_usec); - /* On soft reboot really make sure nothing is left */ - if (objective == MANAGER_SOFT_REBOOT) - broadcast_signal(SIGKILL, /* wait_for_exit= */ false, /* send_sighup= */ false, arg_default_timeout_stop_usec); + finish_remaining_processes(objective); if (!switch_root_dir && objective == MANAGER_SOFT_REBOOT) { /* If no switch root dir is specified, then check if /run/nextroot/ qualifies and use that */