Page MenuHomeFreeBSD

D41415.id125833.diff
No OneTemporary

D41415.id125833.diff

diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -409,7 +409,7 @@
static int sigpipe[2]; /* Pipe to catch a signal during select(). */
static bool RFC3164OutputFormat = true; /* Use legacy format by default. */
-static volatile sig_atomic_t MarkSet, WantDie, WantInitialize, WantReapchild;
+static volatile sig_atomic_t MarkSet, WantDie, WantInitialize;
struct iovlist;
@@ -420,7 +420,6 @@
static const char *cvthname(struct sockaddr *);
static void deadq_enter(pid_t, const char *);
static int deadq_remove(struct deadq_entry *);
-static int deadq_removebypid(pid_t);
static int decode(const char *, const CODE *);
static void die(int) __dead2;
static void dodie(int);
@@ -449,7 +448,6 @@
static void parsemsg(const char *, char *);
static void printsys(char *);
static int p_open(const char *, pid_t *);
-static void reapchild(int);
static const char *ttymsg_check(struct iovec *, int, char *, int);
static void usage(void);
static int validate(struct sockaddr *, const char *);
@@ -528,6 +526,7 @@
int
main(int argc, char *argv[])
{
+ struct sigaction act = { };
int ch, i, s, fdsrmax = 0;
bool bflag = false, pflag = false, Sflag = false;
fd_set *fdsr = NULL;
@@ -769,11 +768,16 @@
(void)strlcpy(consfile.fu_fname, ctty + sizeof _PATH_DEV - 1,
sizeof(consfile.fu_fname));
(void)strlcpy(bootfile, getbootfile(), sizeof(bootfile));
+
+ /* Do not create zombie processes. */
+ act.sa_flags = SA_NOCLDWAIT;
+ if (sigaction(SIGCHLD, &act, NULL) == -1)
+ err(1, "failed to apply signal handler");
+
(void)signal(SIGTERM, dodie);
(void)signal(SIGINT, Debug ? dodie : SIG_IGN);
(void)signal(SIGQUIT, Debug ? dodie : SIG_IGN);
(void)signal(SIGHUP, sighandler);
- (void)signal(SIGCHLD, sighandler);
(void)signal(SIGALRM, domark);
(void)signal(SIGPIPE, SIG_IGN); /* We'll catch EPIPE instead. */
(void)alarm(TIMERINTVL);
@@ -800,8 +804,6 @@
init(0);
else if (WantInitialize)
init(WantInitialize);
- if (WantReapchild)
- reapchild(WantReapchild);
if (MarkSet)
markit();
if (WantDie) {
@@ -865,9 +867,6 @@
case SIGHUP:
WantInitialize = 1;
break;
- case SIGCHLD:
- WantReapchild = 1;
- break;
}
}
return (0);
@@ -2239,31 +2238,6 @@
return ttymsg(iov, iovcnt, line, tmout);
}
-static void
-reapchild(int signo __unused)
-{
- int status;
- pid_t pid;
- struct filed *f;
-
- while ((pid = wait3(&status, WNOHANG, (struct rusage *)NULL)) > 0) {
- /* First, look if it's a process from the dead queue. */
- if (deadq_removebypid(pid))
- continue;
-
- /* Now, look in list of active processes. */
- STAILQ_FOREACH(f, &fhead, next) {
- if (f->f_type == F_PIPE &&
- f->fu_pipe_pid == pid) {
- close_filed(f);
- log_deadchild(pid, status, f->fu_pipe_pname);
- break;
- }
- }
- }
- WantReapchild = 0;
-}
-
/*
* Return a printable representation of a host address.
*/
@@ -3226,19 +3200,11 @@
switch (dq->dq_timeout) {
case 0:
/* Already signalled once, try harder now. */
- if (kill(dq->dq_pid, SIGKILL) != 0)
- (void)deadq_remove(dq);
+ (void)kill(dq->dq_pid, SIGKILL);
+ (void)deadq_remove(dq);
break;
case 1:
- /*
- * Timed out on dead queue, send terminate
- * signal. Note that we leave the removal
- * from the dead queue to reapchild(), which
- * will also log the event (unless the process
- * didn't even really exist, in case we simply
- * drop it from the dead queue).
- */
if (kill(dq->dq_pid, SIGTERM) != 0)
(void)deadq_remove(dq);
else
@@ -3732,18 +3698,6 @@
return (0);
}
-static int
-deadq_removebypid(pid_t pid)
-{
- struct deadq_entry *dq;
-
- TAILQ_FOREACH(dq, &deadq_head, dq_entries) {
- if (dq->dq_pid == pid)
- break;
- }
- return (deadq_remove(dq));
-}
-
static void
log_deadchild(pid_t pid, int status, const char *name)
{

File Metadata

Mime Type
text/plain
Expires
Thu, Feb 26, 12:48 AM (7 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28998260
Default Alt Text
D41415.id125833.diff (3 KB)

Event Timeline