From: Oleg Nesterov Add another trivial helper for the sake of grep. It also auto-documents the fact that ->parent != real_parent implies ->ptrace. No functional changes. Signed-off-by: Oleg Nesterov Acked-by: Roland McGrath Signed-off-by: Andrew Morton --- include/linux/ptrace.h | 4 ++++ kernel/exit.c | 9 ++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff -puN include/linux/ptrace.h~ptrace-introduce-ptrace_reparented-helper include/linux/ptrace.h --- a/include/linux/ptrace.h~ptrace-introduce-ptrace_reparented-helper +++ a/include/linux/ptrace.h @@ -98,6 +98,10 @@ extern void ptrace_untrace(struct task_s extern int ptrace_may_attach(struct task_struct *task); extern int __ptrace_may_attach(struct task_struct *task); +static inline int ptrace_reparented(struct task_struct *child) +{ + return child->real_parent != child->parent; +} static inline void ptrace_link(struct task_struct *child, struct task_struct *new_parent) { diff -puN kernel/exit.c~ptrace-introduce-ptrace_reparented-helper kernel/exit.c --- a/kernel/exit.c~ptrace-introduce-ptrace_reparented-helper +++ a/kernel/exit.c @@ -632,7 +632,7 @@ reparent_thread(struct task_struct *p, s if (unlikely(traced)) { /* Preserve ptrace links if someone else is tracing this child. */ list_del_init(&p->ptrace_list); - if (p->parent != p->real_parent) + if (ptrace_reparented(p)) list_add(&p->ptrace_list, &p->real_parent->ptrace_children); } else { /* If this child is being traced, then we're the one tracing it @@ -799,8 +799,8 @@ static void exit_notify(struct task_stru * only has special meaning to our real parent. */ if (!task_detached(tsk) && thread_group_empty(tsk)) { - int signal = (tsk->parent == tsk->real_parent) - ? tsk->exit_signal : SIGCHLD; + int signal = ptrace_reparented(tsk) ? + SIGCHLD : tsk->exit_signal; do_notify_parent(tsk, signal); } else if (tsk->ptrace) { do_notify_parent(tsk, SIGCHLD); @@ -1203,8 +1203,7 @@ static int wait_task_zombie(struct task_ return 0; } - /* traced means p->ptrace, but not vice versa */ - traced = (p->real_parent != p->parent); + traced = ptrace_reparented(p); if (likely(!traced)) { struct signal_struct *psig; _