158 lines
3.6 KiB
Plaintext
158 lines
3.6 KiB
Plaintext
--- syslogd.c
|
|
+++ syslogd.c 2010-03-29 15:12:11.000000000 +0000
|
|
@@ -565,7 +565,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
|
|
|
|
@@ -1096,6 +1096,7 @@ int main(argc, argv)
|
|
|
|
dprintf("Starting.\n");
|
|
init();
|
|
+ (void) signal(SIGHUP, sighup_handler);
|
|
#ifndef TESTING
|
|
if ( Debug )
|
|
{
|
|
@@ -1167,9 +1168,22 @@ int main(argc, argv)
|
|
(fd_set *) NULL, (struct timeval *) NULL);
|
|
if ( restart )
|
|
{
|
|
+#ifndef _BSD_SOURCE
|
|
+ int omask = sigblock(sigmask(SIGHUP));
|
|
+#else
|
|
+ sigset_t blockhup;
|
|
+ sigemptyset(&blockhup);
|
|
+ sigaddset (&blockhup, SIGHUP);
|
|
+ (void) sigprocmask(SIG_BLOCK, &blockhup, NULL);
|
|
+#endif
|
|
+ restart = 0;
|
|
dprintf("\nReceived SIGHUP, reloading syslogd.\n");
|
|
init();
|
|
- restart = 0;
|
|
+#ifndef _BSD_SOURCE
|
|
+ (void) sigsetmask(omask);
|
|
+#else
|
|
+ (void) sigprocmask (SIG_UNBLOCK, &blockhup, NULL);
|
|
+#endif
|
|
continue;
|
|
}
|
|
if (nfds == 0) {
|
|
@@ -1676,17 +1690,23 @@ void logmsg(pri, msg, from, flags)
|
|
register struct filed *f;
|
|
int fac, prilev;
|
|
int msglen;
|
|
-#ifndef SYSV
|
|
+#ifndef _BSD_SOURCE
|
|
int omask;
|
|
#else
|
|
int lognum;
|
|
+ sigset_t nset, oset;
|
|
#endif
|
|
char *timestamp;
|
|
|
|
dprintf("logmsg: %s, flags %x, from %s, msg %s\n", textpri(pri), flags, from, msg);
|
|
|
|
-#ifndef SYSV
|
|
+#ifndef _BSD_SOURCE
|
|
omask = sigblock(sigmask(SIGHUP)|sigmask(SIGALRM));
|
|
+#else
|
|
+ sigemptyset(&nset);
|
|
+ sigaddset (&nset, SIGHUP);
|
|
+ sigaddset (&nset, SIGALRM);
|
|
+ (void)sigprocmask(SIG_BLOCK, &nset, &oset);
|
|
#endif
|
|
|
|
/*
|
|
@@ -1724,8 +1744,10 @@ void logmsg(pri, msg, from, flags)
|
|
(void) close(f->f_file);
|
|
f->f_file = -1;
|
|
}
|
|
-#ifndef SYSV
|
|
+#ifndef _BSD_SOURCE
|
|
(void) sigsetmask(omask);
|
|
+#else
|
|
+ (void)sigprocmask(SIG_SETMASK, &oset, NULL);
|
|
#endif
|
|
return;
|
|
}
|
|
@@ -1789,8 +1811,10 @@ void logmsg(pri, msg, from, flags)
|
|
}
|
|
}
|
|
}
|
|
-#ifndef SYSV
|
|
+#ifndef _BSD_SOURCE
|
|
(void) sigsetmask(omask);
|
|
+#else
|
|
+ (void)sigprocmask(SIG_SETMASK, &oset, NULL);
|
|
#endif
|
|
}
|
|
#if FALSE
|
|
@@ -2108,7 +2132,7 @@ void wallmsg(f, iov)
|
|
(void) signal(SIGTERM, SIG_DFL);
|
|
(void) alarm(0);
|
|
(void) signal(SIGALRM, endtty);
|
|
-#ifndef SYSV
|
|
+#ifndef _BSD_SOURCE
|
|
(void) signal(SIGTTOU, SIG_IGN);
|
|
(void) sigsetmask(0);
|
|
#endif
|
|
@@ -2178,14 +2202,14 @@ void wallmsg(f, iov)
|
|
void reapchild()
|
|
{
|
|
int saved_errno = errno;
|
|
-#if defined(SYSV) && !defined(linux)
|
|
+#if defined(SYSV) && !defined(_BSD_SOURCE)
|
|
(void) signal(SIGCHLD, reapchild); /* reset signal handler -ASP */
|
|
wait ((int *)0);
|
|
#else
|
|
while (waitpid(-1, (int*)0, WNOHANG|WUNTRACED) > 0)
|
|
;
|
|
#endif
|
|
-#ifdef linux
|
|
+#ifndef _BSD_SOURCE
|
|
(void) signal(SIGCHLD, reapchild); /* reset signal handler -ASP */
|
|
#endif
|
|
errno = saved_errno;
|
|
@@ -2318,7 +2342,9 @@ void debug_switch()
|
|
{
|
|
dprintf("Switching debugging_on to %s\n", (debugging_on == 0) ? "true" : "false");
|
|
debugging_on = (debugging_on == 0) ? 1 : 0;
|
|
+#ifndef _BSD_SOURCE
|
|
signal(SIGUSR1, debug_switch);
|
|
+#endif
|
|
}
|
|
|
|
|
|
@@ -2350,7 +2376,9 @@ void die(int sig)
|
|
(void) snprintf(buf, sizeof(buf), "exiting on signal %d", sig);
|
|
errno = 0;
|
|
logmsg(LOG_SYSLOG|LOG_INFO, buf, LocalHostName, ADDDATE);
|
|
+#ifdef _BSD_SOURCE
|
|
signal(sig, SIG_IGN);
|
|
+#endif
|
|
}
|
|
|
|
void dienow(void)
|
|
@@ -2664,7 +2692,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
|
|
@@ -3061,7 +3088,9 @@ void sighup_handler()
|
|
|
|
{
|
|
restart = 1;
|
|
+#ifndef _BSD_SOURCE
|
|
signal(SIGHUP, sighup_handler);
|
|
+#endif
|
|
return;
|
|
}
|
|
|