Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:dirkmueller:branches:openSUSE:Factory:Rings:1-MinimalX
syslogd
sysklogd-1.4.1-reload.dif
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File sysklogd-1.4.1-reload.dif of Package syslogd
--- syslogd.c | 68 ++++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 26 deletions(-) --- syslogd.c +++ syslogd.c 2022-10-19 09:49:43.134694341 +0000 @@ -544,6 +544,10 @@ static char sccsid[] __attribute__ ((un #include <sys/time.h> #include <sys/resource.h> #include <signal.h> +#ifndef _GNU_SOURCE +typedef void (*sighandler_t)(int); +#endif +static sighandler_t resignal(int signum, sighandler_t handler); #include <netinet/in.h> #include <netdb.h> @@ -618,7 +622,7 @@ char **parts; int inetm = 0; static int debugging_on = 0; static int nlogs = -1; -static int restart = 0; +static volatile sig_atomic_t restart; #define MAXFUNIX 20 @@ -1134,13 +1138,13 @@ int main(argc, argv) leave = 0; - (void) signal(SIGTERM, die); + (void) resignal(SIGTERM, die); /* Make recvfrom() be able to receive EINTR */ (void) signal(SIGINT, Debug ? die : SIG_IGN); (void) signal(SIGQUIT, Debug ? die : SIG_IGN); - (void) signal(SIGCHLD, reapchild); - (void) signal(SIGALRM, domark); - (void) signal(SIGUSR1, Debug ? debug_switch : SIG_IGN); + (void) resignal(SIGCHLD, reapchild); + (void) resignal(SIGUSR1, Debug ? debug_switch : SIG_IGN); (void) signal(SIGXFSZ, SIG_IGN); + (void) resignal(SIGALRM, domark); /* Make recvfrom() be able to receive EINTR */ (void) alarm(TIMERINTVL); /* Create a partial message table for all file descriptors. */ @@ -1161,6 +1165,7 @@ int main(argc, argv) dprintf("Starting.\n"); init(); + (void) resignal(SIGHUP, sighup_handler); #ifndef TESTING if ( Debug ) { @@ -1232,9 +1237,14 @@ int main(argc, argv) (fd_set *) NULL, (struct timeval *) NULL); if ( restart ) { + sigset_t blockhup; + sigemptyset(&blockhup); + sigaddset (&blockhup, SIGHUP); + (void) sigprocmask(SIG_BLOCK, &blockhup, NULL); restart = 0; dprintf("\nReceived SIGHUP, reloading syslogd.\n"); init(); + (void) sigprocmask (SIG_UNBLOCK, &blockhup, NULL); continue; } if (nfds == 0) { @@ -1756,7 +1766,8 @@ void logmsg(pri, msg, from, flags) int msglen; char *timestamp; #ifdef __gnu_linux__ - sigset_t mask; + sigset_t mask, omask; + int lognum; #else #ifndef SYSV sigset_t omask; @@ -1771,7 +1782,7 @@ void logmsg(pri, msg, from, flags) sigemptyset(&mask); sigaddset(&mask, SIGHUP); sigaddset(&mask, SIGALRM); - sigprocmask(SIG_BLOCK, &mask, NULL); + sigprocmask(SIG_BLOCK, &mask, &omask); #else #ifndef SYSV omask = sigblock(sigmask(SIGHUP)|sigmask(SIGALRM)); @@ -1815,7 +1826,7 @@ void logmsg(pri, msg, from, flags) f->f_file = -1; } #ifdef __gnu_linux__ - sigprocmask(SIG_UNBLOCK, &mask, NULL); + sigprocmask(SIG_SETMASK, &omask, NULL); #else #ifndef SYSV (void) sigsetmask(omask); @@ -1884,7 +1895,7 @@ void logmsg(pri, msg, from, flags) } } #ifdef __gnu_linux__ - sigprocmask(SIG_UNBLOCK, &mask, NULL); + sigprocmask(SIG_SETMASK, &omask, NULL); #else #ifndef SYSV (void) sigsetmask(omask); @@ -2213,10 +2224,6 @@ void wallmsg(f, iov) if (fork() == 0) { (void) signal(SIGTERM, SIG_DFL); (void) alarm(0); -#ifndef SYSV - (void) signal(SIGTTOU, SIG_IGN); - (void) sigsetmask(0); -#endif (void) snprintf(greetings, sizeof(greetings), "\r\n\7Message from syslogd@%s at %.24s ...\r\n", (char *) iov[2].iov_base, ctime(&now)); @@ -2281,19 +2288,32 @@ void wallmsg(f, iov) reenter = 0; } +static sighandler_t resignal(int signum, sighandler_t handler) +{ + struct sigaction nact, oact; + sigset_t sigset; + + nact.sa_handler = handler; + sigemptyset (&nact.sa_mask); + + do { + if (sigaction(signum, &nact, &oact) == 0) + break; + } while (errno == EINTR); + + sigemptyset(&sigset); + sigaddset(&sigset, signum); + + sigprocmask(SIG_UNBLOCK, &sigset, NULL); + + return oact.sa_handler; +} + void reapchild() { int saved_errno = errno; -#if defined(SYSV) && !defined(linux) - (void) signal(SIGCHLD, reapchild); /* reset signal handler -ASP */ - wait ((int *)0); -#else while (waitpid(-1, (int*)0, WNOHANG|WUNTRACED) > 0) ; -#endif -#ifdef linux - (void) signal(SIGCHLD, reapchild); /* reset signal handler -ASP */ -#endif errno = saved_errno; } @@ -2403,6 +2423,7 @@ void domark() #ifdef SYSV for (lognum = 0; lognum <= nlogs; lognum++) { f = &Files[lognum]; + } #else for (f = Files; f; f = f->f_next) { #endif @@ -2414,8 +2435,6 @@ void domark() BACKOFF(f); } } - } - (void) signal(SIGALRM, domark); (void) alarm(TIMERINTVL); } @@ -2424,7 +2443,6 @@ void debug_switch() { dprintf("Switching debugging_on to %s\n", (debugging_on == 0) ? "true" : "false"); debugging_on = (debugging_on == 0) ? 1 : 0; - signal(SIGUSR1, debug_switch); } @@ -2774,7 +2792,6 @@ void init() logmsg(LOG_SYSLOG|LOG_INFO, "syslogd " VERSION "." PATCHLEVEL \ ": restart." , LocalHostName, ADDDATE); #endif - (void) signal(SIGHUP, sighup_handler); dprintf("syslogd: restarted.\n"); } #if FALSE @@ -3175,7 +3192,6 @@ static void allocate_log(void) void sighup_handler(int sig) { restart = 1; - signal(SIGHUP, sighup_handler); return; }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor