diff src/syslog2iptables.cpp @ 2:6e88da080f08

initial coding
author carl
date Thu, 24 Nov 2005 10:31:09 -0800
parents 551433a01cab
children 8fe310e5cd44
line wrap: on
line diff
--- a/src/syslog2iptables.cpp	Wed Nov 23 19:29:14 2005 -0800
+++ b/src/syslog2iptables.cpp	Thu Nov 24 10:31:09 2005 -0800
@@ -36,6 +36,9 @@
 #include <signal.h> 	/* header for signal functions */
 #include "includes.h"
 
+extern "C" {
+	void sig_chld(int signo);
+}
 int  debug_syslog  = 0;
 bool syslog_opened = false;
 bool use_syslog    = true;	// false to printf
@@ -196,6 +199,10 @@
 		CONFIG *conf = new_conf();
 		if (conf) {
 			conf->dump();
+			for (int i=0; i<30; i++) {
+				conf->read();
+				sleep(1);
+			}
 			delete conf;
 			return 0;
 		}
@@ -242,6 +249,16 @@
 		exit(1);
 	}
 
+	// setup sigchld handler to prevent zombies
+	struct sigaction act;
+	act.sa_handler = sig_chld;		// Assign sig_chld as our SIGCHLD handler
+	sigemptyset(&act.sa_mask);		// We don't want to block any other signals in this example
+	act.sa_flags = SA_NOCLDSTOP;	// only want children that have terminated
+	if (sigaction(SIGCHLD, &act, NULL) < 0) {
+		my_syslog("failed to setup SIGCHLD handler");
+		exit(1);
+	}
+
 	// only create threads after the fork() in daemon
 	pthread_t tid;
 	if (pthread_create(&tid, 0, config_loader, 0))