]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
softreboot: ensure all processes are killed
authorLuca Boccassi <bluca@debian.org>
Sat, 22 Jul 2023 22:35:40 +0000 (23:35 +0100)
committerLuca Boccassi <bluca@debian.org>
Mon, 24 Jul 2023 09:45:28 +0000 (10:45 +0100)
Having surviving processes is not ready yet as a feature, so ensure
everything is killed on the transition for now

man/systemd-soft-reboot.service.xml
src/core/main.c
test/units/testsuite-82.sh

index 5960cf90a6c42d808284e84efc3522a4e3376984..711cd6e3e987ab62c9f29e11dd03b693ede54e2b 100644 (file)
     url="https://systemd.io/PORTABLE_SERVICES">Portable Services</ulink>, but make sure no resource from
     the host's root filesystem is pinned via <varname>BindPaths=</varname> or similar unit settings,
     otherwise the old root filesystem will be kept in memory as long as the unit is running.</para>
-
-    <para>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
-    <varname>DefaultDependencies=no</varname> and then place
-    <varname>Conflicts=</varname>/<varname>Before=</varname> onto <filename>reboot.target</filename>,
-    <filename>kexec.target</filename>, <filename>poweroff.target</filename> and
-    <filename>halt.target</filename> (but <emphasis>not</emphasis> onto
-    <filename>soft-reboot.target</filename>).</para>
   </refsect1>
 
   <refsect1>
index 7094be8dba0648ecb3685ac3ebc6c5e8213011f7..613783fd70200fd73d7e6801388678a918903313 100644 (file)
@@ -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 */
index a1c82a9fc9d0f87f101886e4eec5220ac0d1c9e2..9e37d0c06f6ca66663b93d17235e62e8f431bf74 100755 (executable)
@@ -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)