Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/ypserv/ypserv Use SA_NOCLDWAIT instead of catching ...



details:   https://anonhg.NetBSD.org/src/rev/e991f2d22148
branches:  trunk
changeset: 579881:e991f2d22148
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Mar 30 15:19:10 2005 +0000

description:
Use SA_NOCLDWAIT instead of catching the signal and waiting. Avoids signal
races the easy way.

diffstat:

 usr.sbin/ypserv/ypserv/ypserv.c |  26 ++++++++------------------
 1 files changed, 8 insertions(+), 18 deletions(-)

diffs (78 lines):

diff -r d79c5a53e7af -r e991f2d22148 usr.sbin/ypserv/ypserv/ypserv.c
--- a/usr.sbin/ypserv/ypserv/ypserv.c   Wed Mar 30 14:18:41 2005 +0000
+++ b/usr.sbin/ypserv/ypserv/ypserv.c   Wed Mar 30 15:19:10 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ypserv.c,v 1.18 2002/07/06 00:42:27 wiz Exp $  */
+/*     $NetBSD: ypserv.c,v 1.19 2005/03/30 15:19:10 christos Exp $     */
 
 /*
  * Copyright (c) 1994 Mats O Jansson <moj%stacken.kth.se@localhost>
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ypserv.c,v 1.18 2002/07/06 00:42:27 wiz Exp $");
+__RCSID("$NetBSD: ypserv.c,v 1.19 2005/03/30 15:19:10 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -84,9 +84,6 @@
 int    main(int, char *[]);
 void   usage(void);
 
-void   sighandler(int);
-
-
 static
 void _msgout(int level, const char *msg)
 {
@@ -276,12 +273,13 @@
        struct sigaction sa;
        int ch, xcreated = 0, one = 1;
 
+       setprogname(argv[0]);
+
 #ifdef LIBWRAP
 #define        GETOPTSTR       "dfl"
 #else
 #define        GETOPTSTR       "df"
 #endif
-
        while ((ch = getopt(argc, argv, GETOPTSTR)) != -1) {
                switch (ch) {
                case 'd':
@@ -339,8 +337,8 @@
 
        ypdb_init();    /* init db stuff */
 
-       sa.sa_handler = sighandler;
-       sa.sa_flags = 0;
+       sa.sa_handler = SIG_IGN;
+       sa.sa_flags = SA_NOCLDWAIT;
        if (sigemptyset(&sa.sa_mask)) {
                _msgout(LOG_ERR, "sigemptyset: %m");
                exit(1);
@@ -449,21 +447,13 @@
 }
 
 void
-sighandler(int sig)
-{
-
-       /* SIGCHLD */
-       while (wait3((int *)NULL, WNOHANG, (struct rusage *)NULL) > 0);
-}
-
-void
 usage(void)
 {
 
 #ifdef LIBWRAP
-#define        USAGESTR        "usage: %s [-d] [-l]\n"
+#define        USAGESTR        "Usage: %s [-d] [-l]\n"
 #else
-#define        USAGESTR        "usage: %s [-d]\n"
+#define        USAGESTR        "Usage: %s [-d]\n"
 #endif
 
        fprintf(stderr, USAGESTR, getprogname());



Home | Main Index | Thread Index | Old Index