summaryrefslogtreecommitdiff
path: root/units/initrd-switch-root.service.in
diff options
context:
space:
mode:
authorFranck Bui <fbui@suse.com>2016-11-23 16:31:24 +0100
committerLennart Poettering <lennart@poettering.net>2016-11-23 16:31:24 +0100
commita4021390fef27f4136497328f2e35e79bc88855d (patch)
tree9237ed94179c62e3461329ca89aee179c068fd76 /units/initrd-switch-root.service.in
parent3d4cf7de48a74726694abbaa09f9804b845ff3ba (diff)
core: consider SIGTERM as a clean exit status for initrd-switch-root.service (#4713)
Since commit 1f0958f640b8717, systemd considers SIGTERM for short-running services (aka Type=oneshot) as a failure. This can be an issue with initrd-switch-root.service as the command run by this service (in order to switch to the new rootfs) may still be running when systemd does the switch. However PID1 sends SIGTERM to all remaining processes right before switching and initrd-switch-root.service can be one of those. After systemd is reexecuted and its previous state is deserialized, systemd notices that initrd-switch-root.service was killed with SIGTERM and considers this as a failure which leads to the emergency shell. To prevent this, this patch teaches systemd to consider a SIGTERM exit as a clean one for this service. It also removes "KillMode=none" since this is pretty useless as the service is never stopped by systemd but it either exits normally or it's killed by a SIGTERM as described previously.
Diffstat (limited to 'units/initrd-switch-root.service.in')
-rw-r--r--units/initrd-switch-root.service.in8
1 files changed, 7 insertions, 1 deletions
diff --git a/units/initrd-switch-root.service.in b/units/initrd-switch-root.service.in
index 82893dafb1..b89f2348c7 100644
--- a/units/initrd-switch-root.service.in
+++ b/units/initrd-switch-root.service.in
@@ -17,4 +17,10 @@ AllowIsolate=yes
Type=oneshot
# we have to use "--force" here, otherwise systemd would umount /run
ExecStart=@rootbindir@/systemctl --no-block --force switch-root /sysroot
-KillMode=none
+
+# Just before switching to the new rootfs, systemd might send us a TERM signal
+# depending on how fast we are to execute the main command and exit. If we get
+# the SIGTERM signal that simply means that we succeed but haven't got enough
+# time to exit properly. Since systemd considers SIGTERM as a failure for
+# short-running process (aka Type=oneshot), instruct it to ignore this case.
+SuccessExitStatus=SIGTERM