summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/faithd/faithd.c26
-rw-r--r--usr.sbin/faithd/tcp.c12
2 files changed, 26 insertions, 12 deletions
diff --git a/usr.sbin/faithd/faithd.c b/usr.sbin/faithd/faithd.c
index b37fb32f108..458a4a19440 100644
--- a/usr.sbin/faithd/faithd.c
+++ b/usr.sbin/faithd/faithd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: faithd.c,v 1.13 2001/09/05 01:31:33 itojun Exp $ */
+/* $OpenBSD: faithd.c,v 1.14 2001/11/05 09:56:01 deraadt Exp $ */
/* $KAME: faithd.c,v 1.40 2001/07/02 14:36:48 itojun Exp $ */
/*
@@ -775,19 +775,26 @@ map4to6(struct sockaddr_in *dst4, struct sockaddr_in6 *dst6)
static void
sig_child(int sig)
{
- int status;
+ int save_errno = errno, status;
+ struct syslog_data sdata = SYSLOG_DATA_INIT;
pid_t pid;
- pid = wait3(&status, WNOHANG, (struct rusage *)0);
- if (pid && WEXITSTATUS(status))
- syslog(LOG_WARNING, "child %d exit status 0x%x", pid, status);
+ while ((pid = wait3(&status, WNOHANG, (struct rusage *)0)) != -1) {
+ if (pid && WEXITSTATUS(status))
+ syslog_r(LOG_WARNING, &sdata,
+ "child %d exit status 0x%x", pid, status);
+ }
+
+ errno = save_errno;
}
void
sig_terminate(int sig)
{
- syslog(LOG_INFO, "Terminating faith daemon");
- exit(EXIT_SUCCESS);
+ struct syslog_data sdata = SYSLOG_DATA_INIT;
+
+ syslog_r(LOG_INFO, &sdata, "Terminating faith daemon");
+ _exit(EXIT_SUCCESS);
}
static void
@@ -848,14 +855,15 @@ exit_failure(const char *fmt, ...)
void
exit_success(const char *fmt, ...)
{
+ struct syslog_data sdata = SYSLOG_DATA_INIT;
va_list ap;
char buf[BUFSIZ];
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
- syslog(LOG_INFO, "%s", buf);
- exit(EXIT_SUCCESS);
+ syslog_r(LOG_INFO, &sdata, "%s", buf);
+ _exit(EXIT_SUCCESS);
}
#ifdef USE_ROUTE
diff --git a/usr.sbin/faithd/tcp.c b/usr.sbin/faithd/tcp.c
index 1fbb996f475..3d9e6653e1b 100644
--- a/usr.sbin/faithd/tcp.c
+++ b/usr.sbin/faithd/tcp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp.c,v 1.6 2001/09/05 01:31:33 itojun Exp $ */
+/* $OpenBSD: tcp.c,v 1.7 2001/11/05 09:56:02 deraadt Exp $ */
/* $KAME: tcp.c,v 1.6 2001/07/02 14:36:49 itojun Exp $ */
/*
@@ -78,22 +78,28 @@ static void relay __P((int, int, const char *, int));
static void
sig_ctimeout(int sig)
{
+ int save_errno = errno;
+ struct syslog_data sdata = SYSLOG_DATA_INIT;
+
/* parent side: record notification from the child */
if (dflag)
- syslog(LOG_DEBUG, "activity timer from child");
+ syslog_r(LOG_DEBUG, &sdata, "activity timer from child");
child_lastactive = time(NULL);
+ errno = save_errno;
}
/* parent will terminate if child dies. */
static void
sig_child(int sig)
{
+ struct syslog_data sdata = SYSLOG_DATA_INIT;
int status;
pid_t pid;
pid = wait3(&status, WNOHANG, (struct rusage *)0);
if (pid && WEXITSTATUS(status))
- syslog(LOG_WARNING, "child %d exit status 0x%x", pid, status);
+ syslog_r(LOG_WARNING, &sdata,
+ "child %d exit status 0x%x", pid, status);
exit_success("terminate connection due to child termination");
}