aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2003-08-12 06:41:53 +0000
committerRoger Dingledine <arma@torproject.org>2003-08-12 06:41:53 +0000
commitc82e13f1f53b2646fd66d2af2732083efb671cf3 (patch)
tree12cd7c5697aa8a4cd9aba426f628014d2262d0a2
parent2aff21f857bb31620f04041c8d16a0c817fc80df (diff)
downloadtor-c82e13f1f53b2646fd66d2af2732083efb671cf3.tar
tor-c82e13f1f53b2646fd66d2af2732083efb671cf3.tar.gz
reap exited dns/cpuworkers
svn:r385
-rw-r--r--configure.in2
-rw-r--r--src/or/main.c8
-rw-r--r--src/or/or.h3
3 files changed, 12 insertions, 1 deletions
diff --git a/configure.in b/configure.in
index 8f906485f..83baf2982 100644
--- a/configure.in
+++ b/configure.in
@@ -134,7 +134,7 @@ AC_CHECK_HEADERS(unistd.h string.h signal.h netdb.h ctype.h poll.h sys/poll.h sy
dnl These headers are not essential
-AC_CHECK_HEADERS(stdint.h sys/types.h inttypes.h)
+AC_CHECK_HEADERS(stdint.h sys/types.h inttypes.h sys/wait.h)
AC_CHECK_FUNCS(gettimeofday ftime)
diff --git a/src/or/main.c b/src/or/main.c
index f3520a8c7..4325c6491 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -25,6 +25,7 @@ static int nfds=0; /* number of connections currently active */
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 @@ static int do_main_loop(void) {
}
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 @@ static void catch(int the_signal) {
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 @@ int tor_main(int argc, char *argv[]) {
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();
diff --git a/src/or/or.h b/src/or/or.h
index 821988b32..20177f6a4 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -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