diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 27d4e9bf2499..602d22cfd3e5 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exit.c,v 1.58 1998/09/12 17:20:02 christos Exp $ */ +/* $NetBSD: kern_exit.c,v 1.59 1998/09/18 18:48:22 christos Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -289,6 +289,29 @@ exit1(p, rv) calcru(p, &p->p_ru->ru_utime, &p->p_ru->ru_stime, NULL); ruadd(p->p_ru, &p->p_stats->p_cru); + /* + * Notify parent that we're gone. If parent has the P_NOCLDWAIT + * flag set, notify init instead (and hope it will handle + * this situation). + */ + if (p->p_pptr->p_flag & P_NOCLDWAIT) { + struct proc *pp = p->p_pptr; + proc_reparent(p, initproc); + /* + * If this was the last child of our parent, notify + * parent, so in case he was wait(2)ing, he will + * continue. + */ + if (pp->p_children.lh_first == NULL) + wakeup((caddr_t)pp); + } + /* + * Notify parent that we're gone. + */ + if ((p->p_flag & P_FSTRACE) == 0) + psignal(p->p_pptr, SIGCHLD); + wakeup((caddr_t)p->p_pptr); + /* * Clear curproc after we've done all operations * that could block, and before tearing down the rest diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 26eb3a19336a..57f4053e8c6f 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_sig.c,v 1.80 1998/09/11 13:25:20 pk Exp $ */ +/* $NetBSD: kern_sig.c,v 1.81 1998/09/18 18:48:23 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1991, 1993 @@ -126,6 +126,19 @@ sigaction1(p, signum, nsa, osa) 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 + p->p_flag &= ~P_NOCLDWAIT; } if ((nsa->sa_flags & SA_NODEFER) == 0) sigaddset(&ps->ps_sigact[signum].sa_mask, signum);