Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Sep 2014 06:25:35 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r270993 - head/sys/kern
Message-ID:  <201409030625.s836PZHY032159@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Wed Sep  3 06:25:34 2014
New Revision: 270993
URL: http://svnweb.freebsd.org/changeset/base/270993

Log:
  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

Modified:
  head/sys/kern/kern_exit.c

Modified: head/sys/kern/kern_exit.c
==============================================================================
--- head/sys/kern/kern_exit.c	Wed Sep  3 05:14:50 2014	(r270992)
+++ head/sys/kern/kern_exit.c	Wed Sep  3 06:25:34 2014	(r270993)
@@ -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. */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201409030625.s836PZHY032159>