From be5ce0af30772ed7648e4637e7a06af3d4b39ffd Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Wed, 23 Oct 2019 14:41:42 +0200 Subject: [PATCH] Simplify, no need to reset signal disposition in handler On modern systems, both *BSD and Linux using GLIBC/musl, the signal's disposition is not reset to SIG_DFL on invocation of its handler. On Linux this is true because GLIBC/musl wraps signal() in sigaction() with the same semantics as BSD. A follow-up commit will refactor to use sigaction(). Signed-off-by: Joachim Nilsson --- src/klogd.c | 9 +-------- src/syslogd.c | 15 +++------------ 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/klogd.c b/src/klogd.c index 8950fdb..8b087b0 100644 --- a/src/klogd.c +++ b/src/klogd.c @@ -360,14 +360,12 @@ void doexit(int signo) void restart(int signo) { - signal(SIGCONT, restart); change_state = 1; caught_TSTP = 0; } void stop_logging(int signo) { - signal(SIGTSTP, stop_logging); change_state = 1; caught_TSTP = 1; } @@ -382,13 +380,8 @@ void reload_daemon(int signo) change_state = 1; reload_symbols = 1; - if (signo == SIGUSR2) { + if (signo == SIGUSR2) ++reload_symbols; - signal(SIGUSR2, reload_daemon); - } else - signal(SIGUSR1, reload_daemon); - - return; } static void Terminate(void) diff --git a/src/syslogd.c b/src/syslogd.c index 3b3abfd..caccf95 100644 --- a/src/syslogd.c +++ b/src/syslogd.c @@ -2297,20 +2297,13 @@ void wallmsg(struct filed *f, struct iovec *iov) void reapchild(int signo) { - int saved_errno = errno; - -#ifdef linux + int saved_errno; int status; - while (wait3(&status, WNOHANG, NULL) > 0) + saved_errno = errno; + while (waitpid(-1, &status, WNOHANG) > 0) ; - signal(SIGCHLD, reapchild); /* reset signal handler -ASP */ -#else - signal(SIGCHLD, reapchild); /* reset signal handler -ASP */ - wait(NULL); -#endif - errno = saved_errno; } @@ -2415,7 +2408,6 @@ void domark(int signo) DupesPending--; } } - (void)signal(SIGALRM, domark); LastAlarm = MarkInterval - MarkSeq; if (DupesPending && LastAlarm > TIMERINTVL) @@ -3095,7 +3087,6 @@ static void logit(char *fmt, ...) void sighup_handler(int signo) { restart = 1; - signal(SIGHUP, sighup_handler); } /**