diff options
author | Oleg Nesterov <oleg@redhat.com> | 2009-09-23 18:56:44 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-24 10:20:59 -0400 |
commit | a7f0765edfd53aed09cb7b0e15863688b39447de (patch) | |
tree | c89adfe418f9988ad4044e0f22827458bdf6b155 /include/linux | |
parent | 1dd3a27326d307952f8ad2499478c84dc7311517 (diff) |
ptrace: __ptrace_detach: do __wake_up_parent() if we reap the tracee
The bug is old, it wasn't cause by recent changes.
Test case:
static void *tfunc(void *arg)
{
int pid = (long)arg;
assert(ptrace(PTRACE_ATTACH, pid, NULL, NULL) == 0);
kill(pid, SIGKILL);
sleep(1);
return NULL;
}
int main(void)
{
pthread_t th;
long pid = fork();
if (!pid)
pause();
signal(SIGCHLD, SIG_IGN);
assert(pthread_create(&th, NULL, tfunc, (void*)pid) == 0);
int r = waitpid(-1, NULL, __WNOTHREAD);
printf("waitpid: %d %m\n", r);
return 0;
}
Before the patch this program hangs, after this patch waitpid() correctly
fails with errno == -ECHILD.
The problem is, __ptrace_detach() reaps the EXIT_ZOMBIE tracee if its
->real_parent is our sub-thread and we ignore SIGCHLD. But in this case
we should wake up other threads which can sleep in do_wait().
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Roland McGrath <roland@redhat.com>
Cc: Vitaly Mayatskikh <vmayatsk@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/sched.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index 848d1f20086e..9e5a88afe6be 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -2059,6 +2059,7 @@ extern int kill_pgrp(struct pid *pid, int sig, int priv); | |||
2059 | extern int kill_pid(struct pid *pid, int sig, int priv); | 2059 | extern int kill_pid(struct pid *pid, int sig, int priv); |
2060 | extern int kill_proc_info(int, struct siginfo *, pid_t); | 2060 | extern int kill_proc_info(int, struct siginfo *, pid_t); |
2061 | extern int do_notify_parent(struct task_struct *, int); | 2061 | extern int do_notify_parent(struct task_struct *, int); |
2062 | extern void __wake_up_parent(struct task_struct *p, struct task_struct *parent); | ||
2062 | extern void force_sig(int, struct task_struct *); | 2063 | extern void force_sig(int, struct task_struct *); |
2063 | extern void force_sig_specific(int, struct task_struct *); | 2064 | extern void force_sig_specific(int, struct task_struct *); |
2064 | extern int send_sig(int, struct task_struct *, int); | 2065 | extern int send_sig(int, struct task_struct *, int); |