2008-01-09 08:03:37

by Roland McGrath

[permalink] [raw]
Subject: [PATCH] show_task: real_parent


The show_task function invoked by sysrq-t et al displays the
pid and parent's pid of each task. It seems more useful to
show the actual process hierarchy here than who is using
ptrace on each process.

Signed-off-by: Roland McGrath <[email protected]>
---
kernel/sched.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 3df84ea..37cf07a 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4918,7 +4918,7 @@ static void show_task(struct task_struct *p)
}
#endif
printk(KERN_CONT "%5lu %5d %6d\n", free,
- task_pid_nr(p), task_pid_nr(p->parent));
+ task_pid_nr(p), task_pid_nr(p->real_parent));

if (state != TASK_RUNNING)
show_stack(p, NULL);


2008-01-09 09:17:38

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH] show_task: real_parent


* Roland McGrath <[email protected]> wrote:

> The show_task function invoked by sysrq-t et al displays the pid and
> parent's pid of each task. It seems more useful to show the actual
> process hierarchy here than who is using ptrace on each process.

> printk(KERN_CONT "%5lu %5d %6d\n", free,
> - task_pid_nr(p), task_pid_nr(p->parent));
> + task_pid_nr(p), task_pid_nr(p->real_parent));

thanks, applied.

you must be hacking ptrace/gdb/strace code right now ;-)

Ingo

2008-01-09 16:05:11

by Linus Torvalds

[permalink] [raw]
Subject: Re: [PATCH] show_task: real_parent



On Wed, 9 Jan 2008, Roland McGrath wrote:
>
> The show_task function invoked by sysrq-t et al displays the
> pid and parent's pid of each task. It seems more useful to
> show the actual process hierarchy here than who is using
> ptrace on each process.

Hmm. It could go both ways. If the problem is some ptrace()/wait4()
interaction issue (which is certainly not unheard of!) the parent that
matters for the kernel may be the right thing to print out.

I wonder if we should just print out both (or perhaps print out the
ptrace parent only if it differs from the normal parent?)

I'll apply this, because I agree that it's sensible in general, I just
wonder how often anybody really even cares about the parent information
when it's not about some wait-related issue..

Linus

2008-01-09 20:16:15

by Roland McGrath

[permalink] [raw]
Subject: Re: [PATCH] show_task: real_parent

I agree with your points. I thought about making it display both.
But I didn't want to worry about breaking scripts that parse console
logs or whatever. Personally I don't think I've ever found the ppid
in that display useful in debugging a ptrace issue. I don't have any
special opinions about this display. I just went on a little crusade
to get rid of task_struct.parent uses that aren't specifically for
its ptrace/wait purpose.


Thanks,
Roland