[PATCH] ps shows wrong ppid

From: Dinakar Guniguntala
Date: Thu Oct 07 2004 - 05:52:20 EST


Hi,

/proc shows the wrong PID as parent in the following case

Process A creates Threads 1 & 2 (using pthread_create)
Thread 2 then forks and execs process B
getppid() for Process B shows Process A (rightly) as parent,
however /proc/B/status shows Thread 3 as PPid (incorrect)

Following patch has been tested and it works ok

Regards,

Dinakar

Signed-off-by: Dinakar Guniguntala <dino@xxxxxxxxxx>

diff -Naurp linux-2.6.9-rc1-orig/fs/proc/array.c linux-2.6.9-rc1/fs/proc/array.c
--- linux-2.6.9-rc1-orig/fs/proc/array.c 2004-08-24 12:32:58.000000000 +0530
+++ linux-2.6.9-rc1/fs/proc/array.c 2004-10-07 15:33:05.465755672 +0530
@@ -169,7 +169,7 @@ static inline char * task_state(struct t
get_task_state(p),
(p->sleep_avg/1024)*100/(1020000000/1024),
p->tgid,
- p->pid, p->pid ? p->real_parent->pid : 0,
+ p->pid, p->pid ? p->group_leader->real_parent->tgid : 0,
p->pid && p->ptrace ? p->parent->pid : 0,
p->uid, p->euid, p->suid, p->fsuid,
p->gid, p->egid, p->sgid, p->fsgid);