Subject: Re: apache2 threads (fwd)
To: None <tech-kern@netbsd.org>
From: Christos Zoulas <christos@astron.com>
List: tech-kern
Date: 09/16/2005 17:55:22
In article <Pine.LNX.4.61.0509151958180.32033@m24s24.vlinux.de>,
Hubert Feyrer  <hubert@feyrer.de> wrote:
>
>Maybe that's of interest here...
>
>  - Hubert
>
>---------- Forwarded message ----------
>Date: Thu, 15 Sep 2005 10:54:17 -0700
>From: Cheese Lottery <cheeselottery@gmail.com>
>To: tech-pkg@netbsd.org
>Subject: Re: apache2 threads
>
>Does anyone use the worker MPM and cgi?
>
>I'm using 3.0_BETA with apache-2.0.54nb5. With the default
>configuration and the included test-cgi script, I get zombie processes
>(?)
>
>15402 ?     ZW   0:00.00 (sh)
>15541 ?     ZW   0:00.00 (sh)
>16815 ?     ZW   0:00.00 (sh)
>18072 ?     ZW   0:00.00 (sh)
>18894 ?     ZW   0:00.00 (sh)
>23604 ?     ZW   0:00.00 (sh)
>23930 ?     ZW   0:00.00 (sh)
>26195 ?     ZW   0:00.00 (sh)
>
>And so on.  Serving up static files seems to work fine.
>
>In the meantime, I use prefork.
>

We should pull up the following to 3.0.

christos

Index: kern_sig.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_sig.c,v
retrieving revision 1.202
retrieving revision 1.208
diff -u -r1.202 -r1.208
--- kern_sig.c	26 Feb 2005 21:34:55 -0000	1.202
+++ kern_sig.c	23 Jul 2005 22:02:13 -0000	1.208
@@ -361,6 +362,18 @@
 					p->p_flag |= P_NOCLDWAIT;
 			} else
 				p->p_flag &= ~P_NOCLDWAIT;
+
+			if (nsa->sa_handler == SIG_IGN) {
+				/*
+				 * Paranoia: same as above.
+				 */
+				if (p->p_pid == 1)
+					p->p_flag &= ~P_CLDSIGIGN;
+				else
+					p->p_flag |= P_CLDSIGIGN;
+			} else
+				p->p_flag &= ~P_CLDSIGIGN;
+				
 		}
 		if ((nsa->sa_flags & SA_NODEFER) == 0)
 			sigaddset(&SIGACTION_PS(ps, signum).sa_mask, signum);
@@ -538,7 +551,13 @@
 	}
 	sigemptyset(&p->p_sigctx.ps_sigcatch);
 	p->p_sigctx.ps_sigwaited = NULL;
-	p->p_flag &= ~P_NOCLDSTOP;
+
+	/*
+	 * Reset no zombies if child dies flag as Solaris does.
+	 */
+	p->p_flag &= ~(P_NOCLDWAIT | P_CLDSIGIGN);
+	if (SIGACTION_PS(ps, SIGCHLD).sa_handler == SIG_IGN)
+		SIGACTION_PS(ps, SIGCHLD).sa_handler = SIG_DFL;
 
 	/*
 	 * Reset stack state to the user stack.
Index: proc.h
===================================================================
RCS file: /cvsroot/src/sys/sys/proc.h,v
retrieving revision 1.197
retrieving revision 1.206
diff -u -r1.197 -r1.206
--- proc.h	26 Feb 2005 22:25:34 -0000	1.197
+++ proc.h	28 Aug 2005 14:57:18 -0000	1.206
@@ -290,6 +296,7 @@
 #define	P_FSTRACE	0x00010000 /* Debugger process being traced by procfs */
 #define	P_NOCLDWAIT	0x00020000 /* No zombies if child dies */
 #define	P_32		0x00040000 /* 32-bit process (used on 64-bit kernels) */
+#define	P_CLDSIGIGN	0x00080000 /* Process is ignoring SIGCHLD */
 #define	P_INEXEC	0x00100000 /* Process is exec'ing and can't be traced */
 #define	P_SYSTRACE	0x00200000 /* Process system call tracing active */
 #define	P_CHTRACED	0x00400000 /* Child has been traced & reparented */