|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
From 60532427251167b8cb2a733e19eb25ecac5c1632 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
Date: Mon, 30 Jan 2017 13:06:10 -0500
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
Subject: [PATCH] systemctl: ignore SIGTERM after switch root
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
https://bugzilla.redhat.com/show_bug.cgi?id=1414904#c14 and #c15.
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
(cherry picked from commit 8a7a9ceab204fb02fd5d93a765b36b31efeb9beb)
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
---
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
src/systemctl/systemctl.c | 13 ++++++++++++-
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
1 file changed, 12 insertions(+), 1 deletion(-)
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
index 4f528f6079..d68c06d9d4 100644
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
--- a/src/systemctl/systemctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
+++ b/src/systemctl/systemctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
@@ -5595,6 +5595,14 @@ static int switch_root(int argc, char *argv[], void *userdata) {
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
+ /* If we are slow to exit after the root switch, the new systemd instance
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
+ * will send us a signal to terminate. Just ignore it and exit normally.
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
+ * This way the unit does not end up as failed.
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
+ */
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
+ r = ignore_signals(SIGTERM, -1);
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
+ if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
+ log_warning_errno(r, "Failed to change disposition of SIGTERM to ignore: %m");
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
+
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
log_debug("Switching root - root: %s; init: %s", root, strna(init));
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
r = sd_bus_call_method(
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
@@ -5606,8 +5614,11 @@ static int switch_root(int argc, char *argv[], void *userdata) {
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
&error,
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
NULL,
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
"ss", root, init);
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
- if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
+ if (r < 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
+ (void) default_signals(SIGTERM, -1);
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
+
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
return log_error_errno(r, "Failed to switch root: %s", bus_error_message(&error, r));
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
+ }
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
}
|