ps,top: add an option to show threads. +260 bytes of code
[oweals/busybox.git] / runit / runsvdir.c
index 9d560e0974caaecc45ec19b868c29dd0ac3e77e6..492c2a57bf3752bf699361c9f03b0b6a46cccf37 100644 (file)
@@ -119,7 +119,7 @@ static NOINLINE pid_t runsv(const char *name)
                        | (1 << SIGTERM)
                        , SIG_DFL);
 #endif
-               execlp("runsv", "runsv", name, NULL);
+               execlp("runsv", "runsv", name, (char *) NULL);
                fatal2_cannot("start runsv ", name);
        }
        return pid;
@@ -129,7 +129,7 @@ static NOINLINE pid_t runsv(const char *name)
 static NOINLINE int do_rescan(void)
 {
        DIR *dir;
-       direntry *d;
+       struct dirent *d;
        int i;
        struct stat s;
        int need_rescan = 0;
@@ -370,26 +370,24 @@ int runsvdir_main(int argc UNUSED_PARAM, char **argv)
                        opt_s_argv[1] = utoa(bb_got_signal);
                        pid = spawn(opt_s_argv);
                        if (pid > 0) {
-                               /* Remebering to wait for _any_ children,
+                               /* Remembering to wait for _any_ children,
                                 * not just pid */
                                while (wait(NULL) != pid)
                                        continue;
                        }
                }
 
-               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 (;;) */
 }