]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
switch-root: don't wait for processes
authorLennart Poettering <lennart@poettering.net>
Tue, 17 Jul 2012 15:44:26 +0000 (17:44 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 17 Jul 2012 15:44:26 +0000 (17:44 +0200)
When we transition from the initrd to the main system, don't reap
processes, so that they can be handled normally after deserialization.

TODO
src/core/killall.c
src/core/killall.h
src/core/main.c
src/core/shutdown.c

diff --git a/TODO b/TODO
index 4ad6076759d206627df0d1dc0bd0f38cc66dfc5c..d1fbed5c58a4ab3971960fbaf54e53fac1e78eff 100644 (file)
--- a/TODO
+++ b/TODO
@@ -34,8 +34,6 @@ Bugfixes:
 
 Features:
 
-* switch-root killing spree: don't waitpid, and think about signalfd() serialization
-
 * flush jobs when switching root
 
 * autorestart of journald after switch-root is broken
index 5f589eaf47430dec365f932fbe9fcec23f0d62e8..6fcaf847cfdb75b2126667d40ffdeff22939e5ee 100644 (file)
@@ -150,7 +150,7 @@ static int killall(int sig) {
         return n_processes;
 }
 
-void broadcast_signal(int sig) {
+void broadcast_signal(int sig, bool wait) {
         sigset_t mask, oldmask;
         int n_processes;
 
@@ -169,7 +169,8 @@ void broadcast_signal(int sig) {
         if (n_processes <= 0)
                 goto finish;
 
-        wait_for_children(n_processes, &mask);
+        if (wait)
+                wait_for_children(n_processes, &mask);
 
 finish:
         sigprocmask(SIG_SETMASK, &oldmask, NULL);
index 8b5bd52de5155e32d6a8c37f33351266a83229d7..d08ac142f0fc93049d35e049bf99cf5f4abd2d8e 100644 (file)
@@ -22,6 +22,6 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-void broadcast_signal(int sig);
+void broadcast_signal(int sig, bool wait);
 
 #endif
index f1f8b21ae000c59b809ed33de72e8c6ea385ffe4..022d05a31b815cf8b9bc11afa887268a2f48a9e4 100644 (file)
@@ -1692,9 +1692,11 @@ finish:
                 watchdog_close(true);
 
                 if (switch_root_dir) {
-                        /* Kill all remaining processes from the initrd */
-                        broadcast_signal(SIGTERM);
-                        broadcast_signal(SIGKILL);
+                        /* Kill all remaining processes from the
+                         * initrd, but don't wait for them, so that we
+                         * can handle the SIGCHLD for them after
+                         * deserializing. */
+                        broadcast_signal(SIGTERM, false);
 
                         /* And switch root */
                         r = switch_root(switch_root_dir);
index 78dccfb72405d21160431d83aa5798f9d3b48b37..105a604542b001cb760a66ff404b978e58f970d0 100644 (file)
@@ -177,10 +177,10 @@ int main(int argc, char *argv[]) {
         mlockall(MCL_CURRENT|MCL_FUTURE);
 
         log_info("Sending SIGTERM to remaining processes...");
-        broadcast_signal(SIGTERM);
+        broadcast_signal(SIGTERM, true);
 
         log_info("Sending SIGKILL to remaining processes...");
-        broadcast_signal(SIGKILL);
+        broadcast_signal(SIGKILL, true);
 
         if (in_container) {
                 need_swapoff = false;