]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: always let the kernel reap zombies when we're about to freeze 1486/head
authorMichal Schmidt <mschmidt@redhat.com>
Wed, 30 Sep 2015 15:08:04 +0000 (17:08 +0200)
committerMichal Schmidt <mschmidt@redhat.com>
Wed, 7 Oct 2015 12:25:51 +0000 (14:25 +0200)
Regardless of whether we're going to spawn a crash shell or not, let the
kernel reap zombies. It's more consistent this way.

src/core/main.c

index 13fa78fed8a80a51bd44e4a7512c35ca45066d0c..2454c8b962109e3027cda234d6bebe2c82439e0d 100644 (file)
@@ -142,6 +142,8 @@ noreturn static void freeze_or_reboot(void) {
 }
 
 noreturn static void crash(int sig) {
+        struct sigaction sa;
+        pid_t pid;
 
         if (getpid() != 1)
                 /* Pass this on immediately, if this is not PID 1 */
@@ -149,11 +151,10 @@ noreturn static void crash(int sig) {
         else if (!arg_dump_core)
                 log_emergency("Caught <%s>, not dumping core.", signal_to_string(sig));
         else {
-                struct sigaction sa = {
+                sa = (struct sigaction) {
                         .sa_handler = nop_signal_handler,
                         .sa_flags = SA_NOCLDSTOP|SA_RESTART,
                 };
-                pid_t pid;
 
                 /* We want to wait for the core process, hence let's enable SIGCHLD */
                 (void) sigaction(SIGCHLD, &sa, NULL);
@@ -209,19 +210,18 @@ noreturn static void crash(int sig) {
         if (arg_crash_chvt >= 0)
                 (void) chvt(arg_crash_chvt);
 
-        if (arg_crash_shell) {
-                struct sigaction sa = {
-                        .sa_handler = SIG_IGN,
-                        .sa_flags = SA_NOCLDSTOP|SA_NOCLDWAIT|SA_RESTART,
-                };
-                pid_t pid;
+        sa = (struct sigaction) {
+                .sa_handler = SIG_IGN,
+                .sa_flags = SA_NOCLDSTOP|SA_NOCLDWAIT|SA_RESTART,
+        };
+
+        /* Let the kernel reap children for us */
+        (void) sigaction(SIGCHLD, &sa, NULL);
 
+        if (arg_crash_shell) {
                 log_notice("Executing crash shell in 10s...");
                 (void) sleep(10);
 
-                /* Let the kernel reap children for us */
-                (void) sigaction(SIGCHLD, &sa, NULL);
-
                 pid = raw_clone(SIGCHLD, NULL);
                 if (pid < 0)
                         log_emergency_errno(errno, "Failed to fork off crash shell: %m");