Do not call event_del() for signals after fork(), just use sigaction()

directly instead - calling libevent functions after fork() w/o
event_reinit() is a bad idea, even if in this case it was harmless.
This commit is contained in:
Nicholas Marriott
2010-08-19 18:29:01 +00:00
parent c2822ca119
commit e3be9b1951
7 changed files with 30 additions and 15 deletions

View File

@@ -62,7 +62,7 @@ set_signals(void(*handler)(int, short, unused void *))
}
void
clear_signals(void)
clear_signals(int after_fork)
{
struct sigaction sigact;
@@ -79,10 +79,25 @@ clear_signals(void)
if (sigaction(SIGTSTP, &sigact, NULL) != 0)
fatal("sigaction failed");
event_del(&ev_sighup);
event_del(&ev_sigchld);
event_del(&ev_sigcont);
event_del(&ev_sigterm);
event_del(&ev_sigusr1);
event_del(&ev_sigwinch);
if (after_fork) {
if (sigaction(SIGHUP, &sigact, NULL) != 0)
fatal("sigaction failed");
if (sigaction(SIGCHLD, &sigact, NULL) != 0)
fatal("sigaction failed");
if (sigaction(SIGCONT, &sigact, NULL) != 0)
fatal("sigaction failed");
if (sigaction(SIGTERM, &sigact, NULL) != 0)
fatal("sigaction failed");
if (sigaction(SIGUSR1, &sigact, NULL) != 0)
fatal("sigaction failed");
if (sigaction(SIGWINCH, &sigact, NULL) != 0)
fatal("sigaction failed");
} else {
event_del(&ev_sighup);
event_del(&ev_sigchld);
event_del(&ev_sigcont);
event_del(&ev_sigterm);
event_del(&ev_sigusr1);
event_del(&ev_sigwinch);
}
}