public inbox for
 help / color / mirror / Atom feed
From: Kevin Buettner <>
Subject: [commit] Handle LWPs that have died without leaving a status
Date: Thu, 10 Nov 2005 21:40:00 -0000	[thread overview]
Message-ID: <20051110144027.4ba0c27d@ironwood.lan> (raw)

I've just committed the patch below.  It's been sitting in one of my
trees for a while and I don't remember all that much about it.  I do
know that without this code, RDA will error out when using certain
linux kernel versions with the message:

    <<< ERROR -- tkill (680, Stopped (signal)) failed: No such process >>>

I believe that this would occur because RDA was attempting to stop a
process which had already exited.  Apparently, there were certain (buggy)
kernels which would fail to leave an exit status.

	* lwp-pool.c (mark_lwp_as_dead_but_interesting): New function.
	(wait_and_handle): Replace lines of code implementing guts of
	new function mark_lwp_as_dead_but_interesting() with call to
	that function.  Make a new call to this function after it
	has been determined that an lwp has exited without leaving a

Index: lwp-pool.c
RCS file: /cvs/src/src/rda/unix/lwp-pool.c,v
retrieving revision 1.4
diff -u -p -r1.4 lwp-pool.c
--- lwp-pool.c	9 Nov 2005 02:16:46 -0000	1.4
+++ lwp-pool.c	10 Nov 2005 21:26:30 -0000
@@ -796,6 +796,17 @@ debug_report_state_change (struct gdbser
+/* Remove (dead) LWP from the hash table and put it on the `interesting'
+   queue.  */
+static void
+mark_lwp_as_dead_but_interesting (struct lwp *l)
+  hash_delete (l);
+  l->state = lwp_state_dead_interesting;
+  if (l->next)
+    queue_delete (l);
+  queue_enqueue (&interesting_queue, l);
 /* Wait for a status from the LWP L (or any LWP, if L is NULL),
    passing FLAGS to waitpid, and record the resulting wait status in
@@ -868,15 +879,7 @@ wait_and_handle (struct gdbserv *serv, s
   l->status = status;
   if (WIFEXITED (status) || WIFSIGNALED (status))
-    {
-      /* Remove dead LWP's from the hash table, and put them in the
-	 interesting queue.  */
-      hash_delete (l);
-      l->state = lwp_state_dead_interesting;
-      if (l->next)
-	queue_delete (l);
-      queue_enqueue (&interesting_queue, l);
-    }
+    mark_lwp_as_dead_but_interesting (l);
       int stopsig;
@@ -1143,9 +1146,24 @@ lwp_pool_stop_all (struct gdbserv *serv)
 	    case lwp_state_running:
 	      /* A 'no such process' error here indicates an NPTL thread
 		 that has exited.  */
-	      kill_lwp (l->pid, SIGSTOP);
-	      l->state = lwp_state_running_stop_pending;
-	      queue_enqueue (&stopping_queue, l);
+	      if (kill_lwp (l->pid, SIGSTOP) < 0)
+		{
+		  /* Thread has exited.  See if a status is available.  */
+		  if (wait_and_handle (serv, l, WNOHANG) < 0)
+		    {
+		      /* Nope, it's truly gone without providing a status.
+		         Put it on the interesting queue so that GDB is
+			 notified that it's gone.  */
+		      l->status = 0;
+		      mark_lwp_as_dead_but_interesting (l);
+		    }
+		}
+	      else
+		{
+		  l->state = lwp_state_running_stop_pending;
+		  queue_enqueue (&stopping_queue, l);
+		}
 	    case lwp_state_stopped:

                 reply	other threads:[~2005-11-10 21:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051110144027.4ba0c27d@ironwood.lan \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).