SIGCHLD SIG_IGN, then wait - warning messages

Wayne Davison wayned at samba.org
Fri Jul 25 05:27:04 EST 2003


On Thu, Jul 24, 2003 at 09:09:48AM -0400, Hardy Merrill wrote:
> What is the status on this?

I finally educated myself on this issue, and would like to propose a
patch.  Since there are reports that zombies can get created when using
SIG_IGN on FreeBSD as well as other unices, I think we should change the
code to catch the signal and cleanup the zombies in the signal handler.
This would make the code similar to the handling in main.c.

..wayne..
-------------- next part --------------
--- socket.c	27 Jan 2003 03:35:09 -0000	1.84
+++ socket.c	24 Jul 2003 19:25:05 -0000
@@ -374,6 +374,14 @@
 }
 
 
+static RETSIGTYPE sigchld_handler(int UNUSED(val)) {
+	signal(SIGCHLD, sigchld_handler);
+#ifdef WNOHANG
+	while (waitpid(-1, NULL, WNOHANG) > 0) {}
+#endif
+}
+
+
 void start_accept_loop(int port, int (*fn)(int, int))
 {
 	int s;
@@ -419,14 +427,7 @@
 
 		if (fd == -1) continue;
 
-		signal(SIGCHLD, SIG_IGN);
-
-		/* we shouldn't have any children left hanging around
-		   but I have had reports that on Digital Unix zombies
-		   are produced, so this ensures that they are reaped */
-#ifdef WNOHANG
-                while (waitpid(-1, NULL, WNOHANG) > 0);
-#endif
+		signal(SIGCHLD, sigchld_handler);
 
 		if ((pid = fork()) == 0) {
 			int ret;


More information about the rsync mailing list