Skip to contentSkip to conversation

show_task: real_parent

PATCH Applied Roland McGrath 3 participants 4 messages Jan 9, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 kernel/sched.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/sched.c +1 -1
index 3df84ea..37cf07a 100644
@@ -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);
Applied
#1 lore raw

kernel/sched.c static void show_task(struct task_struct *p) · line 4921

Quoted 7 lines · Roland McGrath

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.

kernel/sched.c +1 -1
 	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

#2 lore raw
In reply to Roland McGrath
Quoted 5 lines · Roland McGrath

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

#3 lore raw

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