From b12b94b216d073cf50a2a775a6abaeb20133bc52 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 7 Jan 2002 16:16:33 +0000 Subject: If the handler for SIGCHLD is set to SIG_IGN, act as if the SA_NOCLDWAIT (don't create zombies) flag has been specified. This is consistent with most other operating systems and is what XPG4.2 specifies. --- sys/kern/kern_sig.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'sys/kern/kern_sig.c') diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index ce90734b25a..780b1d7bc6e 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.50 2001/11/06 19:53:20 miod Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.51 2002/01/07 16:16:32 millert Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -302,18 +302,17 @@ setsigvec(p, signum, sa) p->p_flag |= P_NOCLDSTOP; else p->p_flag &= ~P_NOCLDSTOP; - if (sa->sa_flags & SA_NOCLDWAIT) { - /* - * Paranoia: since SA_NOCLDWAIT is implemented by - * reparenting the dying child to PID 1 (and - * trust it to reap the zombie), PID 1 itself is - * forbidden to set SA_NOCLDWAIT. - */ - if (p->p_pid == 1) - p->p_flag &= ~P_NOCLDWAIT; - else - p->p_flag |= P_NOCLDWAIT; - } else + /* + * If the SA_NOCLDWAIT flag is set or the handler + * is SIG_IGN we reparent the dying child to PID 1 + * (init) which will reap the zombie. Because we use + * init to do our dirty work we never set P_NOCLDWAIT + * for PID 1. + */ + if (p->p_pid != 1 && ((sa->sa_flags & SA_NOCLDWAIT) || + sa->sa_handler == SIG_IGN)) + p->p_flag |= P_NOCLDWAIT; + else p->p_flag &= ~P_NOCLDWAIT; } if ((sa->sa_flags & SA_RESETHAND) != 0) -- cgit v1.2.3