5509c00
From 1d4d5cd68c250af3b232fa049bd2cde171272ee9 Mon Sep 17 00:00:00 2001
5509c00
From: Lennart Poettering <lennart@poettering.net>
5509c00
Date: Fri, 20 Jun 2014 16:58:21 +0200
5509c00
Subject: [PATCH] core: clean-up signal reset logic when reexec
5509c00
5509c00
There's no need to save the old sigmask, if we are going to die. Let's
5509c00
simplify this. Also, reset all the signal handlers, so that we don't
5509c00
leave SIG_IGN set for some of them across reexec.
5509c00
5509c00
(cherry picked from commit 9bfcda9528636914aef3e0ab91191bb81654c83d)
5509c00
---
5509c00
 src/core/main.c | 10 +++++-----
5509c00
 1 file changed, 5 insertions(+), 5 deletions(-)
5509c00
5509c00
diff --git a/src/core/main.c b/src/core/main.c
5509c00
index e87b8cc8..c9472929 100644
5509c00
--- a/src/core/main.c
5509c00
+++ b/src/core/main.c
5509c00
@@ -1831,7 +1831,7 @@ finish:
5509c00
         if (reexecute) {
5509c00
                 const char **args;
5509c00
                 unsigned i, args_size;
5509c00
-                sigset_t ss, o_ss;
5509c00
+                sigset_t ss;
5509c00
 
5509c00
                 /* Close and disarm the watchdog, so that the new
5509c00
                  * instance can reinitialize it, but doesn't get
5509c00
@@ -1917,8 +1917,10 @@ finish:
5509c00
 
5509c00
                 /* reenable any blocked signals, especially important
5509c00
                  * if we switch from initial ramdisk to init=... */
5509c00
-                sigemptyset(&ss);
5509c00
-                sigprocmask(SIG_SETMASK, &ss, &o_ss);
5509c00
+                reset_all_signal_handlers();
5509c00
+
5509c00
+                assert_se(sigemptyset(&ss) == 0);
5509c00
+                assert_se(sigprocmask(SIG_SETMASK, &ss, NULL) == 0);
5509c00
 
5509c00
                 if (switch_root_init) {
5509c00
                         args[0] = switch_root_init;
5509c00
@@ -1938,8 +1940,6 @@ finish:
5509c00
                         log_error("Failed to execute /bin/sh, giving up: %m");
5509c00
                 } else
5509c00
                         log_warning("Failed to execute /sbin/init, giving up: %m");
5509c00
-
5509c00
-                sigprocmask(SIG_SETMASK, &o_ss, NULL);
5509c00
         }
5509c00
 
5509c00
         if (arg_serialization) {