diff options
author | kib <kib@FreeBSD.org> | 2012-04-02 19:34:56 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2012-04-02 19:34:56 +0000 |
commit | 9ad701f91fade3ec9d7805722dc0ccb8410f3498 (patch) | |
tree | f09897c749f120465dc09dd6f386b3a7ae6829a2 /sys/kern | |
parent | d5677c25b79eefc461a7c9312c4d1b0cd6053e9c (diff) | |
download | FreeBSD-src-9ad701f91fade3ec9d7805722dc0ccb8410f3498.zip FreeBSD-src-9ad701f91fade3ec9d7805722dc0ccb8410f3498.tar.gz |
Add helper function to remove the process from the orphans list and
use it instead of inlined code.
Tested by: pho
MFC after: 3 days
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_exit.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index d1f83e4..a923c02 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -100,6 +100,18 @@ SDT_PROBE_ARGTYPE(proc, kernel, , exit, 0, "int"); /* Hook for NFS teardown procedure. */ void (*nlminfo_release_p)(struct proc *p); +static void +clear_orphan(struct proc *p) +{ + + PROC_LOCK_ASSERT(p, MA_OWNED); + + if (p->p_flag & P_ORPHAN) { + LIST_REMOVE(p, p_orphan); + p->p_flag &= ~P_ORPHAN; + } +} + /* * exit -- death of process. */ @@ -739,10 +751,7 @@ proc_reap(struct thread *td, struct proc *p, int *status, int options, sx_xunlock(&allproc_lock); LIST_REMOVE(p, p_sibling); PROC_LOCK(p); - if (p->p_flag & P_ORPHAN) { - LIST_REMOVE(p, p_orphan); - p->p_flag &= ~P_ORPHAN; - } + clear_orphan(p); PROC_UNLOCK(p); leavepgrp(p); #ifdef PROCDESC @@ -987,10 +996,7 @@ proc_reparent(struct proc *child, struct proc *parent) LIST_REMOVE(child, p_sibling); LIST_INSERT_HEAD(&parent->p_children, child, p_sibling); - if (child->p_flag & P_ORPHAN) { - LIST_REMOVE(child, p_orphan); - child->p_flag &= ~P_ORPHAN; - } + clear_orphan(child); if (child->p_flag & P_TRACED) { LIST_INSERT_HEAD(&child->p_pptr->p_orphans, child, p_orphan); child->p_flag |= P_ORPHAN; |