Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Return the "true" parent's pid as the parent pid (ppid) ...



details:   https://anonhg.NetBSD.org/src/rev/5aa8510a0ca8
branches:  trunk
changeset: 819036:5aa8510a0ca8
user:      kre <kre%NetBSD.org@localhost>
date:      Mon Nov 14 08:55:51 2016 +0000

description:
Return the "true" parent's pid as the parent pid (ppid) via the
various sysctl/procfs interfaces that allow it to be interrogated.
(This is rather than the temporary parent's pid when a process is
being traced and has been reparented.)

XXX The ppid in elf32 core files has not been similarly adjusted,
XXX Should it be ?

diffstat:

 sys/kern/kern_proc.c              |  12 ++++--------
 sys/miscfs/procfs/procfs_status.c |   6 +++---
 2 files changed, 7 insertions(+), 11 deletions(-)

diffs (67 lines):

diff -r 4025735c4274 -r 5aa8510a0ca8 sys/kern/kern_proc.c
--- a/sys/kern/kern_proc.c      Mon Nov 14 08:48:03 2016 +0000
+++ b/sys/kern/kern_proc.c      Mon Nov 14 08:55:51 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_proc.c,v 1.198 2016/09/29 20:40:53 christos Exp $ */
+/*     $NetBSD: kern_proc.c,v 1.199 2016/11/14 08:55:51 kre Exp $      */
 
 /*-
  * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.198 2016/09/29 20:40:53 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.199 2016/11/14 08:55:51 kre Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_kstack.h"
@@ -2186,8 +2186,7 @@
                        strncpy(ep->e_wmesg, l->l_wmesg, WMESGLEN);
                lwp_unlock(l);
        }
-       if (p->p_pptr)
-               ep->e_ppid = p->p_pptr->p_pid;
+       ep->e_ppid = p->p_ppid;
        if (p->p_pgrp && p->p_session) {
                ep->e_pgid = p->p_pgrp->pg_id;
                ep->e_jobc = p->p_pgrp->pg_jobc;
@@ -2247,10 +2246,7 @@
        ki->p_flag |= sysctl_map_flags(sysctl_lflagmap, p->p_lflag);
        ki->p_flag |= sysctl_map_flags(sysctl_stflagmap, p->p_stflag);
        ki->p_pid = p->p_pid;
-       if (p->p_pptr)
-               ki->p_ppid = p->p_pptr->p_pid;
-       else
-               ki->p_ppid = 0;
+       ki->p_ppid = p->p_ppid;
        ki->p_uid = kauth_cred_geteuid(p->p_cred);
        ki->p_ruid = kauth_cred_getuid(p->p_cred);
        ki->p_gid = kauth_cred_getegid(p->p_cred);
diff -r 4025735c4274 -r 5aa8510a0ca8 sys/miscfs/procfs/procfs_status.c
--- a/sys/miscfs/procfs/procfs_status.c Mon Nov 14 08:48:03 2016 +0000
+++ b/sys/miscfs/procfs/procfs_status.c Mon Nov 14 08:55:51 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: procfs_status.c,v 1.36 2009/10/21 21:12:06 rmind Exp $ */
+/*     $NetBSD: procfs_status.c,v 1.37 2016/11/14 08:55:51 kre Exp $   */
 
 /*
  * Copyright (c) 1993
@@ -72,7 +72,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: procfs_status.c,v 1.36 2009/10/21 21:12:06 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_status.c,v 1.37 2016/11/14 08:55:51 kre Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -114,7 +114,7 @@
        mutex_enter(p->p_lock);
 
        pid = p->p_pid;
-       ppid = p->p_pptr ? p->p_pptr->p_pid : 0,
+       ppid = p->p_ppid;
        pgid = p->p_pgrp->pg_id;
        sess = p->p_pgrp->pg_session;
        sid = sess->s_sid;



Home | Main Index | Thread Index | Old Index