linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ps shows wrong ppid
@ 2004-10-07 11:03 Dinakar Guniguntala
  2004-10-19 10:31 ` [PATCH] stat " Dinakar Guniguntala
  0 siblings, 1 reply; 2+ messages in thread
From: Dinakar Guniguntala @ 2004-10-07 11:03 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 401 bytes --]

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@in.ibm.com>


[-- Attachment #2: ps.patch --]
[-- Type: text/plain, Size: 607 bytes --]

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);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] stat shows wrong ppid
  2004-10-07 11:03 [PATCH] ps shows wrong ppid Dinakar Guniguntala
@ 2004-10-19 10:31 ` Dinakar Guniguntala
  0 siblings, 0 replies; 2+ messages in thread
From: Dinakar Guniguntala @ 2004-10-19 10:31 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andrew Morton, Albert Cahalan

[-- Attachment #1: Type: text/plain, Size: 638 bytes --]

Hi,

One more place in fs/proc/array.c where ppid is wrong, which
I missed in my previous mail to lkml

Please apply

Regards,

Dinakar

Signed-off-by: Dinakar Guniguntala <dino@in.ibm.com>


On Thu, Oct 07, 2004 at 04:33:23PM +0530, Dinakar Guniguntala wrote:
> 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 2 as PPid (incorrect)
> 
> Following patch has been tested and it works ok
> 
> Regards,
> 
> Dinakar
> 

[-- Attachment #2: stat.patch --]
[-- Type: text/plain, Size: 527 bytes --]

diff -Naurp linux-2.6.9-rc3-mm2.orig/fs/proc/array.c linux-2.6.9-rc3-mm2/fs/proc/array.c
--- linux-2.6.9-rc3-mm2.orig/fs/proc/array.c	2004-10-19 15:05:58.259265024 +0530
+++ linux-2.6.9-rc3-mm2/fs/proc/array.c	2004-10-19 15:09:52.474658872 +0530
@@ -370,7 +370,7 @@ static int do_task_stat(struct task_stru
 			stime += task->signal->stime;
 		}
 	}
-	ppid = task->pid ? task->real_parent->pid : 0;
+	ppid = task->pid ? task->group_leader->real_parent->tgid : 0;
 	read_unlock(&tasklist_lock);
 
 	if (!whole || num_threads<2)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-10-19 10:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-07 11:03 [PATCH] ps shows wrong ppid Dinakar Guniguntala
2004-10-19 10:31 ` [PATCH] stat " Dinakar Guniguntala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).