Add a handler for SIGCHLD which collects dead childs via wait3(2) so that
"rpc.statd" won't leave zombies arround.
This commit is contained in:
parent
e7fb452657
commit
59d12b63b8
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: statd.c,v 1.18 2001/02/19 23:22:47 cgd Exp $ */
|
||||
/* $NetBSD: statd.c,v 1.19 2001/11/22 12:23:15 tron Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
|
||||
@ -37,7 +37,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: statd.c,v 1.18 2001/02/19 23:22:47 cgd Exp $");
|
||||
__RCSID("$NetBSD: statd.c,v 1.19 2001/11/22 12:23:15 tron Exp $");
|
||||
#endif
|
||||
|
||||
/* main() function for status monitor daemon. Some of the code in this */
|
||||
@ -45,6 +45,7 @@ __RCSID("$NetBSD: statd.c,v 1.18 2001/02/19 23:22:47 cgd Exp $");
|
||||
/* The actual program logic is in the file procs.c */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <ctype.h>
|
||||
@ -88,6 +89,7 @@ static int notify_one __P((DBT *, HostInfo *, void *));
|
||||
static void init_file __P((char *));
|
||||
static int notify_one_host __P((char *));
|
||||
static void die __P((int)) __attribute__((__noreturn__));
|
||||
static void sigchld_handler __P((int));
|
||||
|
||||
int main __P((int, char **));
|
||||
|
||||
@ -98,6 +100,8 @@ main(argc, argv)
|
||||
{
|
||||
int ch;
|
||||
|
||||
(void)signal(SIGCHLD, sigchld_handler);
|
||||
|
||||
while ((ch = getopt(argc, argv, "d")) != (-1)) {
|
||||
switch (ch) {
|
||||
case 'd':
|
||||
@ -623,3 +627,10 @@ die(n)
|
||||
(*db->close)(db);
|
||||
exit(n);
|
||||
}
|
||||
|
||||
static void
|
||||
sigchld_handler(dontcare)
|
||||
int dontcare;
|
||||
{
|
||||
while (wait3(&dontcare, WNOHANG, NULL) > 0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user