summaryrefslogtreecommitdiff
path: root/usr.sbin/syslogd
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2001-01-16 23:58:01 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2001-01-16 23:58:01 +0000
commit8af14a4d561efd395f68fd0b2b2afec07034d250 (patch)
tree29a574e6cb0ddab5bd9a8deff4a6744b85370b60 /usr.sbin/syslogd
parent5dd57eb77ffad3d14f39e68650530219f302f918 (diff)
fix another signal race, and check signal flags even in non-EINTR from select case
Diffstat (limited to 'usr.sbin/syslogd')
-rw-r--r--usr.sbin/syslogd/syslogd.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index 5098d8b176e..b0a396636e4 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syslogd.c,v 1.37 2001/01/11 23:39:12 deraadt Exp $ */
+/* $OpenBSD: syslogd.c,v 1.38 2001/01/16 23:58:00 deraadt Exp $ */
/*
* Copyright (c) 1983, 1988, 1993, 1994
@@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)syslogd.c 8.3 (Berkeley) 4/4/94";
#else
-static char rcsid[] = "$OpenBSD: syslogd.c,v 1.37 2001/01/11 23:39:12 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: syslogd.c,v 1.38 2001/01/16 23:58:00 deraadt Exp $";
#endif
#endif /* not lint */
@@ -194,12 +194,14 @@ int Initialized = 0; /* set when we have initialized ourselves */
int MarkInterval = 20 * 60; /* interval between marks in seconds */
int MarkSeq = 0; /* mark sequence number */
volatile int MarkSet;
+volatile int WantDie;
int SecureMode = 1; /* when true, speak only unix domain socks */
void cfline __P((char *, struct filed *, char *));
char *cvthname __P((struct sockaddr_in *));
int decode __P((const char *, CODE *));
+void dodie __P((int));
void die __P((int));
void domark __P((int));
void markit __P((void));
@@ -289,9 +291,9 @@ main(argc, argv)
linesize++;
line = malloc(linesize);
- (void)signal(SIGTERM, die);
- (void)signal(SIGINT, Debug ? die : SIG_IGN);
- (void)signal(SIGQUIT, Debug ? die : SIG_IGN);
+ (void)signal(SIGTERM, dodie);
+ (void)signal(SIGINT, Debug ? dodie : SIG_IGN);
+ (void)signal(SIGQUIT, Debug ? dodie : SIG_IGN);
(void)signal(SIGCHLD, reapchild);
(void)signal(SIGALRM, domark);
(void)alarm(TIMERINTVL);
@@ -372,6 +374,11 @@ main(argc, argv)
errx(1, "calloc fd_set");
for (;;) {
+ if (MarkSet)
+ markit();
+ if (WantDie)
+ die(WantDie);
+
bzero(fdsr, howmany(fdsrmax+1, NFDBITS) *
sizeof(fd_mask));
@@ -390,8 +397,6 @@ main(argc, argv)
case -1:
if (errno != EINTR)
logerror("select");
- if (MarkSet)
- markit();
continue;
}
@@ -882,6 +887,13 @@ cvthname(f)
}
void
+dodie(signo)
+ int signo;
+{
+ WantDie = signo;
+}
+
+void
domark(signo)
int signo;
{