summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authormjg <mjg@FreeBSD.org>2014-09-03 06:25:34 +0000
committermjg <mjg@FreeBSD.org>2014-09-03 06:25:34 +0000
commit25686bf39b4af295921d0360845a60f7009370d5 (patch)
tree32ac706ce6817d81a73de2654cf0afb12964b7b6 /sys/kern
parentdb9c4f5e7266deb5f2b13123e142c88ea77ac8fb (diff)
downloadFreeBSD-src-25686bf39b4af295921d0360845a60f7009370d5.zip
FreeBSD-src-25686bf39b4af295921d0360845a60f7009370d5.tar.gz
Fix up proc_realparent to always return correct process.
Prior to the change it would always return initproc for non-traced processes. This fixes ps apparently always returning 1 as ppid. Pointy hat: mjg Reported by: many MFC after: 1 week
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_exit.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index b321d97..1dbb997 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -104,8 +104,12 @@ proc_realparent(struct proc *child)
sx_assert(&proctree_lock, SX_LOCKED);
if ((child->p_treeflag & P_TREE_ORPHANED) == 0) {
- return (child->p_pptr->p_pid == child->p_oppid ?
- child->p_pptr : initproc);
+ if (child->p_oppid == 0 ||
+ child->p_pptr->p_pid == child->p_oppid)
+ parent = child->p_pptr;
+ else
+ parent = initproc;
+ return (parent);
}
for (p = child; (p->p_treeflag & P_TREE_FIRST_ORPHAN) == 0;) {
/* Cannot use LIST_PREV(), since the list head is not known. */
OpenPOWER on IntegriCloud