FreeBSD/sys/kern/sys_procdesc.c
/*
 * procdesc_exit() - notify a process descriptor that its process is exiting.
 * We use the proctree_lock to ensure that process exit either happens
 * strictly before or strictly after a concurrent call to procdesc_close().
 */
notify a process descriptor that its process is exiting.
We use the proctree_lock to ensure that process exit either happens
strictly before or strictly after a concurrent call to procdesc_close().
notify a process descriptor that its process is exiting . We use the proctree_lock to ensure that process exit either happens strictly before or strictly after a concurrent call to procdesc_close () .
int
procdesc_exit(struct proc *p)
{
	struct procdesc *pd;
	sx_assert(&proctree_lock, SA_XLOCKED);
	PROC_LOCK_ASSERT(p, MA_OWNED);
	KASSERT(p->p_procdesc != NULL, ("procdesc_exit: p_procdesc NULL"));
	pd = p->p_procdesc;
	PROCDESC_LOCK(pd);
	KASSERT((pd->pd_flags & PDF_CLOSED) == 0 || p->p_pptr == initproc,
	    ("procdesc_exit: closed && parent not init"));
	pd->pd_flags |= PDF_EXITED;
	pd->pd_xstat = KW_EXITCODE(p->p_xexit, p->p_xsig);
	if (pd->pd_flags & PDF_CLOSED) {
		PROCDESC_UNLOCK(pd);
		pd->pd_proc = NULL;
		p->p_procdesc = NULL;
		procdesc_free(pd);
		return (1);
	}
	if (pd->pd_flags & PDF_SELECTED) {
		pd->pd_flags &= ~PDF_SELECTED;
		selwakeup(&pd->pd_selinfo);
	}
	KNOTE_LOCKED(&pd->pd_selinfo.si_note, NOTE_EXIT);
	PROCDESC_UNLOCK(pd);
	return (0);
}
int procdesc_exit ( struct proc * p ) { struct procdesc * pd ; sx_assert ( & proctree_lock , SA_XLOCKED ) ; PROC_LOCK_ASSERT ( p , MA_OWNED ) ; KASSERT ( p -> p_procdesc != NULL , ( " " ) ) ; pd = p -> p_procdesc ; PROCDESC_LOCK ( pd ) ; KASSERT ( ( pd -> pd_flags & PDF_CLOSED ) == 0 || p -> p_pptr == initproc , ( " " ) ) ; pd -> pd_flags |= PDF_EXITED ; pd -> pd_xstat = KW_EXITCODE ( p -> p_xexit , p -> p_xsig ) ; if ( pd -> pd_flags & PDF_CLOSED ) { PROCDESC_UNLOCK ( pd ) ; pd -> pd_proc = NULL ; p -> p_procdesc = NULL ; procdesc_free ( pd ) ; return ( 1 ) ; } if ( pd -> pd_flags & PDF_SELECTED ) { pd -> pd_flags &= ~ PDF_SELECTED ; selwakeup ( & pd -> pd_selinfo ) ; } KNOTE_LOCKED ( & pd -> pd_selinfo . si_note , NOTE_EXIT ) ; PROCDESC_UNLOCK ( pd ) ; return ( 0 ) ; }
procdesc_exit() - notify a process descriptor that its process is exiting.
procdesc_exit () - notify a process descriptor that its process is exiting .
/*
	 * If the process descriptor has been closed, then we have nothing
	 * to do; return 1 so that init will get SIGCHLD and do the reaping.
	 * Clean up the procdesc now rather than letting it happen during
	 * that reap.
	 */