From: Luca Boccassi Date: Sat, 22 Jul 2023 22:35:40 +0000 (+0100) Subject: softreboot: ensure all processes are killed X-Git-Tag: v254-rc3~2^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b41ab9b3f44663b0ac0471de7e3c87db47b28c01;p=thirdparty%2Fsystemd.git softreboot: ensure all processes are killed Having surviving processes is not ready yet as a feature, so ensure everything is killed on the transition for now --- diff --git a/man/systemd-soft-reboot.service.xml b/man/systemd-soft-reboot.service.xml index 5960cf90a6c..711cd6e3e98 100644 --- a/man/systemd-soft-reboot.service.xml +++ b/man/systemd-soft-reboot.service.xml @@ -122,14 +122,6 @@ url="https://systemd.io/PORTABLE_SERVICES">Portable Services, but make sure no resource from the host's root filesystem is pinned via BindPaths= or similar unit settings, otherwise the old root filesystem will be kept in memory as long as the unit is running. - - If units shall be left running until the very end of shutdown during a soft reboot operation, but - shall be terminated regularly during other forms of shutdown, it's recommended to set - DefaultDependencies=no and then place - Conflicts=/Before= onto reboot.target, - kexec.target, poweroff.target and - halt.target (but not onto - soft-reboot.target). diff --git a/src/core/main.c b/src/core/main.c index 7094be8dba0..613783fd702 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1871,6 +1871,9 @@ static int do_reexecute( * 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); if (!switch_root_dir && objective == MANAGER_SOFT_REBOOT) { /* If no switch root dir is specified, then check if /run/nextroot/ qualifies and use that */ diff --git a/test/units/testsuite-82.sh b/test/units/testsuite-82.sh index a1c82a9fc9d..9e37d0c06f6 100755 --- a/test/units/testsuite-82.sh +++ b/test/units/testsuite-82.sh @@ -20,14 +20,10 @@ if [ -f /run/testsuite82.touch3 ]; then read -r x <&5 test "$x" = "oinkoink" - # Check that the surviving service is still around - test "$(systemctl show -P ActiveState testsuite-82-survive.service)" = "active" + # Check that no service is still around + test "$(systemctl show -P ActiveState testsuite-82-survive.service)" != "active" test "$(systemctl show -P ActiveState testsuite-82-nosurvive.service)" != "active" - # Take out the big guns now, and kill the service via SIGKILL (SIGTERM is blocked after all, see below) - systemctl --signal=KILL kill testsuite-82-survive.service - systemctl stop testsuite-82-survive.service - # All succeeded, exit cleanly now elif [ -f /run/testsuite82.touch2 ]; then @@ -47,8 +43,8 @@ elif [ -f /run/testsuite82.touch2 ]; then systemd-notify --fd=3 --pid=parent 3<"$T" rm "$T" - # Check that the surviving service is still around - test "$(systemctl show -P ActiveState testsuite-82-survive.service)" = "active" + # Check that no service is still around + test "$(systemctl show -P ActiveState testsuite-82-survive.service)" != "active" test "$(systemctl show -P ActiveState testsuite-82-nosurvive.service)" != "active" # Test that we really are in the new overlayfs root fs @@ -86,8 +82,8 @@ elif [ -f /run/testsuite82.touch ]; then systemd-notify --fd=3 --pid=parent 3<"$T" rm "$T" - # Check that the surviving service is still around - test "$(systemctl show -P ActiveState testsuite-82-survive.service)" = "active" + # Check that no service survived, regardless of the configuration + test "$(systemctl show -P ActiveState testsuite-82-survive.service)" != "active" test "$(systemctl show -P ActiveState testsuite-82-nosurvive.service)" != "active" # This time we test the /run/nextroot/ root switching logic. (We synthesize a new rootfs from the old via overlayfs)