linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PTRACE PATCH] Report detached thread exit to the debugger
@ 2003-06-30  3:43 Daniel Jacobowitz
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Jacobowitz @ 2003-06-30  3:43 UTC (permalink / raw)
  To: torvalds, linux-kernel

Right now, CLONE_DETACHED threads silently vanish from GDB's sight when
they exit.  This patch lets the thread report its exit to the debugger,
and then be auto-reaped as soon as it is collected, instead of being
reaped as soon as it exits and not reported at all.

GDB works either way, but this is more correct and will be useful for some
later GDB patches.

Please apply - thanks!

diff -Nru a/kernel/exit.c b/kernel/exit.c
--- a/kernel/exit.c	Sat Jun 21 21:50:35 2003
+++ b/kernel/exit.c	Sat Jun 21 21:50:35 2003
@@ -651,6 +651,8 @@
 	if (tsk->exit_signal != -1) {
 		int signal = tsk->parent == tsk->real_parent ? tsk->exit_signal : SIGCHLD;
 		do_notify_parent(tsk, signal);
+	} else if (tsk->ptrace) {
+		do_notify_parent(tsk, SIGCHLD);
 	}
 
 	tsk->state = TASK_ZOMBIE;
@@ -715,7 +717,7 @@
 	tsk->exit_code = code;
 	exit_notify(tsk);
 
-	if (tsk->exit_signal == -1)
+	if (tsk->exit_signal == -1 && tsk->ptrace == 0)
 		release_task(tsk);
 
 	schedule();
@@ -859,7 +861,7 @@
 		BUG_ON(state != TASK_DEAD);
 		return 0;
 	}
-	if (unlikely(p->exit_signal == -1))
+	if (unlikely(p->exit_signal == -1 && p->ptrace == 0))
 		/*
 		 * This can only happen in a race with a ptraced thread
 		 * dying on another processor.
@@ -889,8 +891,12 @@
 		/* Double-check with lock held.  */
 		if (p->real_parent != p->parent) {
 			__ptrace_unlink(p);
-			do_notify_parent(p, p->exit_signal);
 			p->state = TASK_ZOMBIE;
+			/* If this is a detached thread, this is where it goes away.  */
+			if (p->exit_signal == -1)
+				release_task (p);
+			else
+				do_notify_parent(p, p->exit_signal);
 			p = NULL;
 		}
 		write_unlock_irq(&tasklist_lock);

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PTRACE PATCH] Report detached thread exit to the debugger
@ 2003-06-22  1:51 Daniel Jacobowitz
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Jacobowitz @ 2003-06-22  1:51 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel

Right now, CLONE_DETACHED threads silently vanish from GDB's sight when they
exit.  This patch lets report exit to the debugger, and then be auto-reaped
as soon as it collects them, instead of being released as soon as they exit.

GDB works either way, but this is more correct and will be useful for some
later GDB patches.

Please apply - thanks!

diff -Nru a/kernel/exit.c b/kernel/exit.c
--- a/kernel/exit.c	Sat Jun 21 21:50:35 2003
+++ b/kernel/exit.c	Sat Jun 21 21:50:35 2003
@@ -651,6 +651,8 @@
 	if (tsk->exit_signal != -1) {
 		int signal = tsk->parent == tsk->real_parent ? tsk->exit_signal : SIGCHLD;
 		do_notify_parent(tsk, signal);
+	} else if (tsk->ptrace) {
+		do_notify_parent(tsk, SIGCHLD);
 	}
 
 	tsk->state = TASK_ZOMBIE;
@@ -715,7 +717,7 @@
 	tsk->exit_code = code;
 	exit_notify(tsk);
 
-	if (tsk->exit_signal == -1)
+	if (tsk->exit_signal == -1 && tsk->ptrace == 0)
 		release_task(tsk);
 
 	schedule();
@@ -859,7 +861,7 @@
 		BUG_ON(state != TASK_DEAD);
 		return 0;
 	}
-	if (unlikely(p->exit_signal == -1))
+	if (unlikely(p->exit_signal == -1 && p->ptrace == 0))
 		/*
 		 * This can only happen in a race with a ptraced thread
 		 * dying on another processor.
@@ -889,8 +891,12 @@
 		/* Double-check with lock held.  */
 		if (p->real_parent != p->parent) {
 			__ptrace_unlink(p);
-			do_notify_parent(p, p->exit_signal);
 			p->state = TASK_ZOMBIE;
+			/* If this is a detached thread, this is where it goes away.  */
+			if (p->exit_signal == -1)
+				release_task (p);
+			else
+				do_notify_parent(p, p->exit_signal);
 			p = NULL;
 		}
 		write_unlock_irq(&tasklist_lock);

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-06-30  3:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-30  3:43 [PTRACE PATCH] Report detached thread exit to the debugger Daniel Jacobowitz
  -- strict thread matches above, loose matches on Subject: below --
2003-06-22  1:51 Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).