diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-01-31 10:36:30 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-31 10:36:30 -0500 |
commit | fccdf28c86a61714b9d611edcdc5db61a0eb2ede (patch) | |
tree | 8f04840bd1a4363df953c72e0b7229a183b6b540 | |
parent | 877777d77690d741c93404fd176da7f5327c2878 (diff) | |
parent | 750e550eba362096d56a35104c6a32631aa67b8e (diff) |
Merge pull request #5192 from keszybz/systemctl-ignore-sigterm
Fix for initrd-switch-root failing and causing emergency.target to be started.
-rw-r--r-- | src/systemctl/systemctl.c | 21 | ||||
-rw-r--r-- | units/initrd-switch-root.service.in | 1 | ||||
-rw-r--r-- | units/systemd-vconsole-setup.service.in | 1 |
3 files changed, 16 insertions, 7 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 41e8d6075a..a20ca1bcb5 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -5655,16 +5655,22 @@ static int switch_root(int argc, char *argv[], void *userdata) { } /* Instruct PID1 to exclude us from its killing spree applied during - * the transition from the initrd to the main system otherwise we would - * exit with a failure status even though the switch to the new root - * has succeed. */ - if (in_initrd()) - argv_cmdline[0] = '@'; + * the transition. Otherwise we would exit with a failure status even + * though the switch to the new root has succeed. */ + argv_cmdline[0] = '@'; r = acquire_bus(BUS_MANAGER, &bus); if (r < 0) return r; + /* If we are slow to exit after the root switch, the new systemd instance + * will send us a signal to terminate. Just ignore it and exit normally. + * This way the unit does not end up as failed. + */ + r = ignore_signals(SIGTERM, -1); + if (r < 0) + log_warning_errno(r, "Failed to change disposition of SIGTERM to ignore: %m"); + log_debug("Switching root - root: %s; init: %s", root, strna(init)); r = sd_bus_call_method( @@ -5676,8 +5682,11 @@ static int switch_root(int argc, char *argv[], void *userdata) { &error, NULL, "ss", root, init); - if (r < 0) + if (r < 0) { + (void) default_signals(SIGTERM, -1); + return log_error_errno(r, "Failed to switch root: %s", bus_error_message(&error, r)); + } return 0; } diff --git a/units/initrd-switch-root.service.in b/units/initrd-switch-root.service.in index 219748d19b..d31497f5e3 100644 --- a/units/initrd-switch-root.service.in +++ b/units/initrd-switch-root.service.in @@ -16,4 +16,3 @@ AllowIsolate=yes [Service] Type=oneshot ExecStart=@rootbindir@/systemctl --no-block switch-root /sysroot -KillMode=none diff --git a/units/systemd-vconsole-setup.service.in b/units/systemd-vconsole-setup.service.in index 2bd1fd1a5d..8bb75c6a4f 100644 --- a/units/systemd-vconsole-setup.service.in +++ b/units/systemd-vconsole-setup.service.in @@ -9,6 +9,7 @@ Description=Setup Virtual Console Documentation=man:systemd-vconsole-setup.service(8) man:vconsole.conf(5) DefaultDependencies=no +Before=initrd-switch-root.target shutdown.target ConditionPathExists=/dev/tty0 [Service] |