runsvdir: straighten some convoluted code. logic is unchanged
authorDenis Vlasenko <vda.linux@googlemail.com>
Tue, 11 Nov 2008 09:33:24 +0000 (09:33 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Tue, 11 Nov 2008 09:33:24 +0000 (09:33 -0000)
runit/runsvdir.c

index 9d560e0974caaecc45ec19b868c29dd0ac3e77e6..f6733048547ef7751909220b40b431f0f2ac07a4 100644 (file)
@@ -377,19 +377,17 @@ int runsvdir_main(int argc UNUSED_PARAM, char **argv)
                        }
                }
 
-               switch (bb_got_signal) {
-               case SIGHUP:
+               if (bb_got_signal == SIGHUP) {
                        for (i = 0; i < svnum; i++)
                                if (sv[i].pid)
                                        kill(sv[i].pid, SIGTERM);
-                       /* Fall through */
-               default: /* SIGTERM (or SIGUSRn if we are init) */
-                       /* Exit unless we are init */
-                       if (getpid() == 1)
-                               break;
-                       return (SIGHUP == bb_got_signal) ? 111 : EXIT_SUCCESS;
                }
+               /* SIGHUP or SIGTERM (or SIGUSRn if we are init) */
+               /* Exit unless we are init */
+               if (getpid() != 1)
+                       return (SIGHUP == bb_got_signal) ? 111 : EXIT_SUCCESS;
 
+               /* init continues to monitor services forever */
                bb_got_signal = 0;
        } /* for (;;) */
 }