On Wed, Sep 03, 2014 at 06:25:35AM +0000, Mateusz Guzik wrote:
> 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
No, this is my bug.  Thank you for fixing it.  It is a consequence of
the last minute 'safety' change I did.

>   Reported by:        many
>   MFC after:  1 week
I suggest to merge in 3 days.

> 
> 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. */

Attachment: pgpjazYeePads.pgp
Description: PGP signature

Reply via email to