*: add optimization barrier to all "G trick" locations
[oweals/busybox.git] / runit / svlogd.c
index 2dc8cb987ea6759ad2c302f9f6be2b27efa15e6c..d7da180930e0ef9353d20374b2e5ba9f51f3fda2 100644 (file)
@@ -106,7 +106,7 @@ struct globals {
 #define fl_flag_0      (G.fl_flag_0     )
 #define dirn           (G.dirn          )
 #define INIT_G() do { \
-       PTR_TO_GLOBALS = xzalloc(sizeof(G)); \
+       SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
        linemax = 1000; \
        /*buflen = 1024;*/ \
        linecomplete = 1; \
@@ -222,9 +222,11 @@ static unsigned processorstart(struct logdir *ld)
                int fd;
 
                /* child */
-               signal(SIGTERM, SIG_DFL);
-               signal(SIGALRM, SIG_DFL);
-               signal(SIGHUP, SIG_DFL);
+               bb_signals(0
+                       + (1 << SIGTERM)
+                       + (1 << SIGALRM)
+                       + (1 << SIGHUP)
+                       , SIG_DFL);
                sig_unblock(SIGTERM);
                sig_unblock(SIGALRM);
                sig_unblock(SIGHUP);
@@ -252,7 +254,7 @@ static unsigned processorstart(struct logdir *ld)
                prog[1] = (char*)"-c";
                prog[2] = ld->processor;
                prog[3] = NULL;
-               execve("/bin/sh", prog, environ);
+               execv("/bin/sh", prog);
                bb_perror_msg_and_die(FATAL"cannot %s processor %s", "run", ld->name);
        }
        ld->ppid = pid;
@@ -265,7 +267,7 @@ static unsigned processorstop(struct logdir *ld)
 
        if (ld->ppid) {
                sig_unblock(SIGHUP);
-               while (wait_pid(&wstat, ld->ppid) == -1)
+               while (safe_waitpid(ld->ppid, &wstat, 0) == -1)
                        pause2cannot("wait for processor", ld->name);
                sig_block(SIGHUP);
                ld->ppid = 0;
@@ -794,7 +796,7 @@ static void sig_child_handler(int sig_no)
 
        if (verbose)
                bb_error_msg(INFO"sig%s received", "child");
-       while ((pid = wait_nohang(&wstat)) > 0) {
+       while ((pid = wait_any_nohang(&wstat)) > 0) {
                for (l = 0; l < dirn; ++l) {
                        if (dir[l].ppid == pid) {
                                dir[l].ppid = 0;
@@ -903,10 +905,10 @@ int svlogd_main(int argc, char **argv)
        sigaddset(&blocked_sigset, SIGALRM);
        sigaddset(&blocked_sigset, SIGHUP);
        sigprocmask(SIG_BLOCK, &blocked_sigset, NULL);
-       sig_catch(SIGTERM, sig_term_handler);
-       sig_catch(SIGCHLD, sig_child_handler);
-       sig_catch(SIGALRM, sig_alarm_handler);
-       sig_catch(SIGHUP, sig_hangup_handler);
+       bb_signals_recursive(1 << SIGTERM, sig_term_handler);
+       bb_signals_recursive(1 << SIGCHLD, sig_child_handler);
+       bb_signals_recursive(1 << SIGALRM, sig_alarm_handler);
+       bb_signals_recursive(1 << SIGHUP, sig_hangup_handler);
 
        logdirs_reopen();