commit 883136492c6d52d6acb644af581d338571968e09 Author: Matthias Rampke Date: Tue Apr 17 23:33:16 2012 +0200 kill zombies if the parent set SIG_IGN on SIGCHLD fix for http://bugs.dragonflybsd.org/issues/2349 diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index f3ffb2b..3b5b780 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -534,11 +534,12 @@ exit1(int rv) KNOTE(&p->p_klist, NOTE_EXIT); /* - * Notify parent that we're gone. If parent has the PS_NOCLDWAIT - * flag set, notify process 1 instead (and hope it will handle - * this situation). + * Notify parent that we're gone. If parent has the PS_NOCLDWAIT + * flag set, or if the handler is set to SIG_IGN, notify process 1 + * instead (and hope it will handle this situation). */ - if (p->p_pptr->p_sigacts->ps_flag & PS_NOCLDWAIT) { + if (p->p_pptr->p_sigacts->ps_flag & + (PS_NOCLDWAIT | PS_CLDSIGIGN)) { struct proc *pp = p->p_pptr; PHOLD(pp); diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index f3ce05c..fd905cd 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -321,6 +321,10 @@ kern_sigaction(int sig, struct sigaction *act, struct sigaction *oact) } else { p->p_sigacts->ps_flag &= ~PS_NOCLDWAIT; } + if (ps->ps_sigact[_SIG_IDX(SIGCHLD)] == SIG_IGN) + ps->ps_flag |= PS_CLDSIGIGN; + else + ps->ps_flag &= ~PS_CLDSIGIGN; } /* * Set bit in p_sigignore for signals that are set to SIG_IGN, @@ -433,7 +437,9 @@ execsigs(struct proc *p) /* * Reset no zombies if child dies flag as Solaris does. */ - p->p_sigacts->ps_flag &= ~PS_NOCLDWAIT; + p->p_sigacts->ps_flag &= ~(PS_NOCLDWAIT | PS_CLDSIGIGN); + if (ps->ps_sigact[_SIG_IDX(SIGCHLD)] == SIG_IGN) + ps->ps_sigact[_SIG_IDX(SIGCHLD)] = SIG_DFL; } /* diff --git a/sys/sys/param.h b/sys/sys/param.h index 17f8456..f15d0a0 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -90,9 +90,10 @@ * 300100 - 3.1 master * 300101 - i4b (ISDN) removal * 300102 - is now just a link of + * 300103 - if SIG_IGN is set on SIGCHLD, do not keep zombie children */ #undef __DragonFly_version -#define __DragonFly_version 300102 /* propagated to newvers */ +#define __DragonFly_version 300103 /* propagated to newvers */ #include diff --git a/sys/sys/proc.h b/sys/sys/proc.h index ee829b4..2220707 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -112,6 +112,7 @@ struct pgrp { #define PS_NOCLDWAIT 0x0001 /* No zombies if child dies */ #define PS_NOCLDSTOP 0x0002 /* No SIGCHLD when children stop. */ +#define PS_CLDSIGIGN 0x0004 /* The SIGCHLD handler is SIG_IGN. */ /* * pargs, used to hold a copy of the command line, if it had a sane