Use sigaction(2) to setup automatic disposal of child processes after
daemonizing. This is more portable and avoids zombie "rpc.statd" processes after an NFS client running e.g. Mac OS X shuts down. Reviewed by christos@.
This commit is contained in:
parent
58c31114a4
commit
0b2d4e954a
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: statd.c,v 1.26 2006/03/17 02:41:31 elad Exp $ */
|
||||
/* $NetBSD: statd.c,v 1.27 2006/03/28 15:21:00 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.26 2006/03/17 02:41:31 elad Exp $");
|
||||
__RCSID("$NetBSD: statd.c,v 1.27 2006/03/28 15:21:00 tron Exp $");
|
||||
#endif
|
||||
|
||||
/* main() function for status monitor daemon. Some of the code in this */
|
||||
@ -101,11 +101,6 @@ main(argc, argv)
|
||||
struct sigaction nsa;
|
||||
int maxrec = RPC_MAXDATASIZE;
|
||||
|
||||
sigemptyset(&nsa.sa_mask);
|
||||
nsa.sa_flags = SA_NOCLDSTOP|SA_NOCLDWAIT;
|
||||
nsa.sa_handler = SIG_IGN;
|
||||
(void)sigaction(SIGCHLD, &nsa, NULL);
|
||||
|
||||
while ((ch = getopt(argc, argv, "d")) != (-1)) {
|
||||
switch (ch) {
|
||||
case 'd':
|
||||
@ -140,6 +135,12 @@ main(argc, argv)
|
||||
*/
|
||||
if (!debug)
|
||||
daemon(0, 0);
|
||||
|
||||
sigemptyset(&nsa.sa_mask);
|
||||
nsa.sa_flags = SA_NOCLDSTOP|SA_NOCLDWAIT;
|
||||
nsa.sa_handler = SIG_IGN;
|
||||
(void)sigaction(SIGCHLD, &nsa, NULL);
|
||||
|
||||
pidfile(NULL);
|
||||
openlog("rpc.statd", 0, LOG_DAEMON);
|
||||
if (debug)
|
||||
|
Loading…
Reference in New Issue
Block a user