[or-cvs] reap exited dns/cpuworkers

Roger Dingledine arma at seul.org
Tue Aug 12 06:41:57 UTC 2003


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	main.c or.h 
Log Message:
reap exited dns/cpuworkers



Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- main.c	11 Aug 2003 20:22:48 -0000	1.79
+++ main.c	12 Aug 2003 06:41:53 -0000	1.80
@@ -25,6 +25,7 @@
 
 static int please_dumpstats=0; /* whether we should dump stats during the loop */
 static int please_fetch_directory=0; /* whether we should fetch a new directory */
+static int please_reap_children=0; /* whether we should waitpid for exited children*/
 
 /* private key */
 static crypto_pk_env_t *privatekey=NULL;
@@ -527,6 +528,10 @@
       }
       please_fetch_directory = 0;
     }
+    if(please_reap_children) {
+      while(waitpid(-1,NULL,WNOHANG)) ; /* keep reaping until no more zombies */
+      please_reap_children = 0;
+    }
     if(prepare_for_poll(&timeout) < 0) {
       log(LOG_DEBUG,"do_main_loop(): prepare_for_poll failed, exiting.");
       return -1;
@@ -591,6 +596,8 @@
     case SIGUSR1:
       please_dumpstats = 1;
       break;
+    case SIGCHLD:
+      please_reap_children = 1;
     default:
       log(LOG_ERR,"Caught signal that we can't handle??");
   }
@@ -845,6 +852,7 @@
   signal (SIGTERM, catch);
   signal (SIGUSR1, catch); /* to dump stats to stdout */
   signal (SIGHUP,  catch); /* to reload directory */
+  signal (SIGCHLD, catch); /* for exiting dns/cpu workers */
 
   crypto_global_init();
   crypto_seed_rng();

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -d -r1.103 -r1.104
--- or.h	12 Aug 2003 03:16:15 -0000	1.103
+++ or.h	12 Aug 2003 06:41:53 -0000	1.104
@@ -36,6 +36,9 @@
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
 #ifdef HAVE_SYS_FCNTL_H
 #include <sys/fcntl.h>
 #endif



More information about the tor-commits mailing list