Linus, I got a bugreport where a ptrace'd task would end up in an unkillable zombie state if the (real) parent of the task happened to ignore SIGCHLD. The patch below should fix the problem. I attached a self-contained test program. If the bug is present, you should see: FAILURE: child PID seems to be still around! at the end (and there will be an unkillable zombie). --david This patch fixes a problem where a ptrace'd task would end up in an unkillable zombie state if the (real) parent happens to ignore SIGCHLD. The problem was due to the fact that while the task is being ptraced, it may not be considered detached, since nobody may have tried to do do_notify_parent(p, SIGCHLD) before the task got ptrace'd. If the task exits while being ptraced, the ptracing task collects the exiting task's status via wait_task_zombie(), which restores the real parent and then attempts to send SIGCHLD to the real parent. However, since the real parent ignores SIGCHLD, this "fails" and exit_signal gets reset to -1. When returning from do_notify_parent(), wait_task_zombie() failed to notice that the task is now detached and should be released. Since it failed to notice that, it never did the release_task() and that's how we ended up with the unkillable zombie. Signed-off-by: davidm@hpl.hp.com ===== kernel/exit.c 1.141 vs edited ===== --- 1.141/kernel/exit.c 2004-07-06 19:32:23 -07:00 +++ edited/kernel/exit.c 2004-07-16 14:50:16 -07:00 @@ -1027,6 +1027,13 @@ else { do_notify_parent(p, p->exit_signal); write_unlock_irq(&tasklist_lock); + /* do_notify_parent() may have noticed + that the real parent didn't care + about SIGCHLD and may have reset + exit_signal to -1. If so, release + task now. */ + if (p->exit_signal == -1) + release_task(p); } p = NULL; }