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)
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;
}
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;
case SIGUSR1:
please_dumpstats = 1;
break;
+ case SIGCHLD:
+ please_reap_children = 1;
default:
log(LOG_ERR,"Caught signal that we can't handle??");
}
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();