Add NOCLDWAIT (from FreeBSD)

This commit is contained in:
christos 1998-09-18 18:48:22 +00:00
parent 4efafd6886
commit eb1a214078
2 changed files with 38 additions and 2 deletions

View File

@ -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

View File

@ -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);