Skip to content

Commit b41ab9b

Browse files
committed
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
1 parent 3835b9a commit b41ab9b

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

man/systemd-soft-reboot.service.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,6 @@
122122
url="https://systemd.io/PORTABLE_SERVICES">Portable Services</ulink>, but make sure no resource from
123123
the host's root filesystem is pinned via <varname>BindPaths=</varname> or similar unit settings,
124124
otherwise the old root filesystem will be kept in memory as long as the unit is running.</para>
125-
126-
<para>If units shall be left running until the very end of shutdown during a soft reboot operation, but
127-
shall be terminated regularly during other forms of shutdown, it's recommended to set
128-
<varname>DefaultDependencies=no</varname> and then place
129-
<varname>Conflicts=</varname>/<varname>Before=</varname> onto <filename>reboot.target</filename>,
130-
<filename>kexec.target</filename>, <filename>poweroff.target</filename> and
131-
<filename>halt.target</filename> (but <emphasis>not</emphasis> onto
132-
<filename>soft-reboot.target</filename>).</para>
133125
</refsect1>
134126

135127
<refsect1>

src/core/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,6 +1871,9 @@ static int do_reexecute(
18711871
* SIGCHLD for them after deserializing. */
18721872
if (IN_SET(objective, MANAGER_SWITCH_ROOT, MANAGER_SOFT_REBOOT))
18731873
broadcast_signal(SIGTERM, /* wait_for_exit= */ false, /* send_sighup= */ true, arg_default_timeout_stop_usec);
1874+
/* On soft reboot really make sure nothing is left */
1875+
if (objective == MANAGER_SOFT_REBOOT)
1876+
broadcast_signal(SIGKILL, /* wait_for_exit= */ false, /* send_sighup= */ false, arg_default_timeout_stop_usec);
18741877

18751878
if (!switch_root_dir && objective == MANAGER_SOFT_REBOOT) {
18761879
/* If no switch root dir is specified, then check if /run/nextroot/ qualifies and use that */

test/units/testsuite-82.sh

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@ if [ -f /run/testsuite82.touch3 ]; then
2020
read -r x <&5
2121
test "$x" = "oinkoink"
2222

23-
# Check that the surviving service is still around
24-
test "$(systemctl show -P ActiveState testsuite-82-survive.service)" = "active"
23+
# Check that no service is still around
24+
test "$(systemctl show -P ActiveState testsuite-82-survive.service)" != "active"
2525
test "$(systemctl show -P ActiveState testsuite-82-nosurvive.service)" != "active"
2626

27-
# Take out the big guns now, and kill the service via SIGKILL (SIGTERM is blocked after all, see below)
28-
systemctl --signal=KILL kill testsuite-82-survive.service
29-
systemctl stop testsuite-82-survive.service
30-
3127
# All succeeded, exit cleanly now
3228

3329
elif [ -f /run/testsuite82.touch2 ]; then
@@ -47,8 +43,8 @@ elif [ -f /run/testsuite82.touch2 ]; then
4743
systemd-notify --fd=3 --pid=parent 3<"$T"
4844
rm "$T"
4945

50-
# Check that the surviving service is still around
51-
test "$(systemctl show -P ActiveState testsuite-82-survive.service)" = "active"
46+
# Check that no service is still around
47+
test "$(systemctl show -P ActiveState testsuite-82-survive.service)" != "active"
5248
test "$(systemctl show -P ActiveState testsuite-82-nosurvive.service)" != "active"
5349

5450
# Test that we really are in the new overlayfs root fs
@@ -86,8 +82,8 @@ elif [ -f /run/testsuite82.touch ]; then
8682
systemd-notify --fd=3 --pid=parent 3<"$T"
8783
rm "$T"
8884

89-
# Check that the surviving service is still around
90-
test "$(systemctl show -P ActiveState testsuite-82-survive.service)" = "active"
85+
# Check that no service survived, regardless of the configuration
86+
test "$(systemctl show -P ActiveState testsuite-82-survive.service)" != "active"
9187
test "$(systemctl show -P ActiveState testsuite-82-nosurvive.service)" != "active"
9288

9389
# This time we test the /run/nextroot/ root switching logic. (We synthesize a new rootfs from the old via overlayfs)

0 commit comments

Comments
 (0)