changeset 52:cde52a8b894d draft

Respond to SIGCHLD with a wait so we don't leave zombies around.
author Roy Marples <roy@marples.name>
date Sat, 27 Jan 2007 13:31:39 +0000
parents 037d27d470b2
children 2bb8e0848f28
files ChangeLog client.c signals.c
diffstat 3 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Jan 18 14:17:10 2007 +0000
+++ b/ChangeLog	Sat Jan 27 13:31:39 2007 +0000
@@ -1,3 +1,5 @@
+We now work with SIGCHLD and call wait so that we don't leave any
+zombies lying around.
 For infinite timeout, we now resent the last request at +TIMEOUT_MINI
 intervals until TIMEOUT_MINI_INF is reached, thanks to siadak.
 We now return a non zero exit code on SIGTERM and SIGINT if we have not
--- a/client.c	Thu Jan 18 14:17:10 2007 +0000
+++ b/client.c	Sat Jan 27 13:31:39 2007 +0000
@@ -19,7 +19,9 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <sys/types.h>
 #include <sys/select.h>
+#include <sys/wait.h>
 #include <arpa/inet.h>
 #ifdef __linux__
 #include <netinet/ether.h>
@@ -232,19 +234,24 @@
 	{
 	  switch (sig)
 	    {
+	    case SIGCHLD:
+	      /* Silently ignore this signal and wait for it
+		 This stops zombies */
+	      wait (0);
+	      break;
 	    case SIGINT:
-	      logger (LOG_INFO, "receieved SIGINT, stopping");
+	      logger (LOG_INFO, "received SIGINT, stopping");
 	      retval = (! daemonised);
 	      goto eexit;
 
 	    case SIGTERM:
-	      logger (LOG_INFO, "receieved SIGTERM, stopping");
+	      logger (LOG_INFO, "received SIGTERM, stopping");
 	      retval = (! daemonised);
 	      goto eexit;
 
 	    case SIGALRM:
 
-	      logger (LOG_INFO, "receieved SIGALRM, renewing lease");
+	      logger (LOG_INFO, "received SIGALRM, renewing lease");
 	      switch (state)
 		{
 		case STATE_BOUND:
@@ -277,7 +284,7 @@
 		}
 	      else
 		logger (LOG_ERR,
-			"receieved SIGHUP, but no we have lease to release");
+			"received SIGHUP, but no we have lease to release");
 	      retval = 0;
 	      goto eexit;
 
--- a/signals.c	Thu Jan 18 14:17:10 2007 +0000
+++ b/signals.c	Sat Jan 27 13:31:39 2007 +0000
@@ -57,6 +57,7 @@
   signal (SIGALRM, signal_handler);
   signal (SIGTERM, signal_handler);
   signal (SIGINT, signal_handler);
+  signal (SIGCHLD, signal_handler);
 }
 
 /* Quick little function to setup the rfds. Will return the