Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 95152
b: refs/heads/master
c: 53b6f9f
h: refs/heads/master
v: v3
  • Loading branch information
Oleg Nesterov authored and Linus Torvalds committed Apr 30, 2008
1 parent 7dedeb5 commit 95f3b3c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2800d8d19e51414403df8144eaa214bb03400b87
refs/heads/master: 53b6f9fbd3b63af14b4f6268e8b5b80d178d05bc
4 changes: 4 additions & 0 deletions trunk/include/linux/ptrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ extern void ptrace_untrace(struct task_struct *child);
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)
{
Expand Down
9 changes: 4 additions & 5 deletions trunk/kernel/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ reparent_thread(struct task_struct *p, struct task_struct *father, int traced)
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
Expand Down Expand Up @@ -865,8 +865,8 @@ static void exit_notify(struct task_struct *tsk, int group_dead)
* 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);
Expand Down Expand Up @@ -1269,8 +1269,7 @@ static int wait_task_zombie(struct task_struct *p, int noreap,
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;
Expand Down

0 comments on commit 95f3b3c

Please sign in to comment.