diff options
Diffstat (limited to 'runit/svlogd.c')
-rw-r--r-- | runit/svlogd.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/runit/svlogd.c b/runit/svlogd.c index 294e31aca..02c305696 100644 --- a/runit/svlogd.c +++ b/runit/svlogd.c | |||
@@ -412,19 +412,32 @@ static void processorstart(struct logdir *ld) | |||
412 | int fd; | 412 | int fd; |
413 | 413 | ||
414 | /* child */ | 414 | /* child */ |
415 | /* Non-ignored signals revert to SIG_DFL on exec anyway */ | 415 | /* Non-ignored signals revert to SIG_DFL on exec anyway. |
416 | * But we can get signals BEFORE execl(), this is unlikely | ||
417 | * but wouldn't be good... | ||
418 | */ | ||
416 | /*bb_signals(0 | 419 | /*bb_signals(0 |
417 | + (1 << SIGTERM) | 420 | + (1 << SIGTERM) |
421 | //+ (1 << SIGCHLD) | ||
418 | + (1 << SIGALRM) | 422 | + (1 << SIGALRM) |
419 | + (1 << SIGHUP) | 423 | + (1 << SIGHUP) |
420 | , SIG_DFL);*/ | 424 | , SIG_DFL);*/ |
421 | sig_unblock(SIGTERM); | 425 | /* runit 2.1.2 does not unblock SIGCHLD, a bug? we do: */ |
422 | sig_unblock(SIGALRM); | 426 | sigprocmask(SIG_UNBLOCK, &blocked_sigset, NULL); |
423 | sig_unblock(SIGHUP); | ||
424 | 427 | ||
425 | if (verbose) | 428 | if (verbose) |
426 | bb_error_msg(INFO"processing: %s/%s", ld->name, ld->fnsave); | 429 | bb_error_msg(INFO"processing: %s/%s", ld->name, ld->fnsave); |
427 | fd = xopen(ld->fnsave, O_RDONLY|O_NDELAY); | 430 | |
431 | fd = open_or_warn(ld->fnsave, O_RDONLY|O_NDELAY); | ||
432 | /* Used to have xopen() above, but it causes infinite restarts of processor | ||
433 | * if file is gone - which can happen even because of _us_! | ||
434 | * Users report that if on reboot, time is reset to before existing | ||
435 | * logfiles creation time, rmoldest() deletes the newest logfile (!) | ||
436 | * and we end up here trying to open this now-deleted file. | ||
437 | */ | ||
438 | if (fd < 0) | ||
439 | _exit(0); /* fake "success": do not run processor again */ | ||
440 | |||
428 | xmove_fd(fd, 0); | 441 | xmove_fd(fd, 0); |
429 | ld->fnsave[26] = 't'; /* <- that's why we need sv_ch! */ | 442 | ld->fnsave[26] = 't'; /* <- that's why we need sv_ch! */ |
430 | fd = xopen(ld->fnsave, O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT); | 443 | fd = xopen(ld->fnsave, O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT); |
@@ -1098,10 +1111,10 @@ int svlogd_main(int argc, char **argv) | |||
1098 | sigaddset(&blocked_sigset, SIGALRM); | 1111 | sigaddset(&blocked_sigset, SIGALRM); |
1099 | sigaddset(&blocked_sigset, SIGHUP); | 1112 | sigaddset(&blocked_sigset, SIGHUP); |
1100 | sigprocmask(SIG_BLOCK, &blocked_sigset, NULL); | 1113 | sigprocmask(SIG_BLOCK, &blocked_sigset, NULL); |
1101 | bb_signals_recursive_norestart(1 << SIGTERM, sig_term_handler); | 1114 | bb_signals_norestart(1 << SIGTERM, sig_term_handler); |
1102 | bb_signals_recursive_norestart(1 << SIGCHLD, sig_child_handler); | 1115 | bb_signals_norestart(1 << SIGCHLD, sig_child_handler); |
1103 | bb_signals_recursive_norestart(1 << SIGALRM, sig_alarm_handler); | 1116 | bb_signals_norestart(1 << SIGALRM, sig_alarm_handler); |
1104 | bb_signals_recursive_norestart(1 << SIGHUP, sig_hangup_handler); | 1117 | bb_signals_norestart(1 << SIGHUP, sig_hangup_handler); |
1105 | 1118 | ||
1106 | /* Without timestamps, we don't have to print each line | 1119 | /* Without timestamps, we don't have to print each line |
1107 | * separately, so we can look for _last_ newline, not first, | 1120 | * separately, so we can look for _last_ newline, not first, |