[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-inetutils] [PATCH] Fix race condition making syslogd exit with non-
From: |
Guillem Jover |
Subject: |
[bug-inetutils] [PATCH] Fix race condition making syslogd exit with non-zero status |
Date: |
Sun, 6 Dec 2009 05:38:22 +0100 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
There's a race condition when the parent sets up the SIGALRM and the
child tries to notify its parent the initialization has finished,
causing it to exit with a non-zero status. We setup our own SIGTERM
handler before calling waitdaemon instead.
* syslogd/syslogd.c (doexit): New function declaration.
(main): Install doexit as SIGTERM handler. Send SIGTERM instead
of SIGALRM to the parent process.
(doexit): New function.
---
syslogd/syslogd.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/syslogd/syslogd.c b/syslogd/syslogd.c
index bbe790b..ffdd2b3 100644
--- a/syslogd/syslogd.c
+++ b/syslogd/syslogd.c
@@ -258,6 +258,7 @@ void cfline (const char *, struct filed *);
const char *cvthname (struct sockaddr_in *);
int decode (const char *, CODE *);
void die (int);
+void doexit (int);
void domark (int);
void fprintlog (struct filed *, const char *, int, const char *);
void init (int);
@@ -460,6 +461,7 @@ main (int argc, char *argv[])
IMO, the GNU/Linux distributors should fix there booting
sequence. But we still keep the approach. */
+ signal (SIGTERM, doexit);
ppid = waitdaemon (0, 0, 30);
if (ppid < 0)
error (1, errno, "could not become daemon");
@@ -594,7 +596,7 @@ main (int argc, char *argv[])
/* If we're doing waitdaemon(), tell the parent to exit,
we are ready to roll. */
if (ppid)
- kill (ppid, SIGALRM);
+ kill (ppid, SIGTERM);
for (;;)
{
@@ -1504,6 +1506,12 @@ logerror (const char *type)
}
RETSIGTYPE
+doexit (int signo ARG_UNUSED)
+{
+ _exit (0);
+}
+
+RETSIGTYPE
die (int signo)
{
struct filed *f;
--
1.6.5.4
- [bug-inetutils] [PATCH] Fix race condition making syslogd exit with non-zero status,
Guillem Jover <=