From 9b9c5b215ac07ce32ce1b3fcd05198af55bc95a1 Mon Sep 17 00:00:00 2001 From: skeezix Date: Wed, 17 Feb 2010 14:28:47 -0500 Subject: [PATCH] Added anit-zombie measures to evmapperd --- apps/pndevmapperd.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/apps/pndevmapperd.c b/apps/pndevmapperd.c index 8a49d6d..d6a6991 100644 --- a/apps/pndevmapperd.c +++ b/apps/pndevmapperd.c @@ -18,6 +18,8 @@ #include // for errno #include // for time(2) #include // for isdigit +#include // for sigaction +#include // for wait #include // for keys //#include "../../kernel-rip/input.h" // for keys @@ -99,12 +101,12 @@ unsigned int g_evmap_max = 0; */ void dispatch_key ( int keycode, int val ); void dispatch_event ( int code, int val ); +void sigchld_handler ( int n ); static void usage ( char *argv[] ) { printf ( "%s [-d]\n", argv [ 0 ] ); printf ( "-d\tDaemon mode; detach from terminal, chdir to /tmp, suppress output. Optional.\n" ); printf ( "-l#\tLog-it; -l is 0-and-up (or all), and -l2 means 2-and-up (not all); l[0-3] for now. Log goes to /tmp/pndevmapperd.log\n" ); - printf ( "Signal: HUP the process to force reload of configuration and reset the notifier watch paths\n" ); return; } @@ -342,6 +344,18 @@ int main ( int argc, char *argv[] ) { exit ( -1 ); } // spin + /* set up sigchld -- don't want zombies all over; well, we do, but not process zombies + */ + sigset_t ss; + sigemptyset ( &ss ); + + struct sigaction siggy; + siggy.sa_handler = sigchld_handler; + siggy.sa_mask = ss; /* implicitly blocks the origin signal */ + siggy.sa_flags = 0; /* don't need anything */ + + sigaction ( SIGCHLD, &siggy, NULL ); + /* actually try to do something useful */ @@ -598,3 +612,13 @@ void dispatch_event ( int code, int val ) { return; } + +void sigchld_handler ( int n ) { + + pnd_log ( pndn_rem, "---[ SIGCHLD received ]---\n" ); + + int status; + wait ( &status ); + + return; +} -- 2.39.5