[netperf-dev] netperf2 commit notice r425 - trunk/src

raj at netperf.org raj at netperf.org
Tue Jul 12 11:33:05 PDT 2011


Author: raj
Date: 2011-07-12 11:33:05 -0700 (Tue, 12 Jul 2011)
New Revision: 425

Modified:
   trunk/src/netserver.c
Log:
we want to avoid defunct processes when we are forking from the forground

Modified: trunk/src/netserver.c
===================================================================
--- trunk/src/netserver.c	2011-07-12 17:40:29 UTC (rev 424)
+++ trunk/src/netserver.c	2011-07-12 18:33:05 UTC (rev 425)
@@ -105,6 +105,11 @@
 
 #if HAVE_SIGNAL_H
 #include <signal.h>
+/* some OS's have SIGCLD defined as SIGCHLD */
+#ifndef SIGCLD
+#define SIGCLD SIGCHLD
+#endif /* SIGCLD */
+      
 #endif
 
 #if !defined(HAVE_SETSID)
@@ -897,7 +902,6 @@
   }
 
 #if defined(HAVE_FORK)
-  FILE *rd_null_fp;    /* Used to redirect from "/dev/null". */
 
   /* flush the usual suspects */
   fflush(stdin);
@@ -905,6 +909,8 @@
   fflush(stderr);
   fflush(where);
 
+  signal(SIGCLD,SIG_IGN);
+
   switch (fork()) {
   case -1:
     fprintf(where,
@@ -934,7 +940,13 @@
        want to reap some children */
 #if !defined(HAVE_SETSID)
     /* Only call "waitpid()" if "setsid()" is not used. */
-    while(waitpid(-1, NULL, WNOHANG) > 0) { }
+    while(waitpid(-1, NULL, WNOHANG) > 0) {
+      if (debug) {
+	fprintf(where,
+		"%s: reaped a child process\n",
+		__FUNCTION__);
+      }
+    }
 #endif
     break;
   }
@@ -1274,11 +1286,6 @@
       setpgrp();
 #endif /* HAVE_SETSID */
 
-      /* some OS's have SIGCLD defined as SIGCHLD */
-#ifndef SIGCLD
-#define SIGCLD SIGCHLD
-#endif /* SIGCLD */
-      
       signal(SIGCLD, SIG_IGN);
 
       /* ok, we can start accepting control connections now */



More information about the netperf-dev mailing list