]> Git Repo - binutils.git/blobdiff - gdb/lin-lwp.c
Fix two ``attach'' related bugs involving threads.
[binutils.git] / gdb / lin-lwp.c
index 22d9d74796c58a57350f60a91a6b284f3a5fbfb1..9931df56f7c13c8af50c7e07c0aafd051c7f5a37 100644 (file)
@@ -352,6 +352,14 @@ lin_lwp_attach_lwp (ptid_t ptid, int verbose)
 
   gdb_assert (is_lwp (ptid));
 
+  /* Make sure SIGCHLD is blocked.  We don't want SIGCHLD events
+     to interrupt either the ptrace() or waitpid() calls below.  */
+  if (! sigismember (&blocked_mask, SIGCHLD))
+    {
+      sigaddset (&blocked_mask, SIGCHLD);
+      sigprocmask (SIG_BLOCK, &blocked_mask, NULL);
+    }
+
   if (verbose)
     printf_filtered ("[New %s]\n", target_pid_to_str (ptid));
 
@@ -383,6 +391,16 @@ lin_lwp_attach_lwp (ptid_t ptid, int verbose)
 
       lp->stopped = 1;
     }
+  else
+    {
+      /* We assume that the LWP representing the original process
+        is already stopped.  Mark it as stopped in the data structure
+        that the lin-lwp layer uses to keep track of threads.  Note
+        that this won't have already been done since the main thread
+        will have, we assume, been stopped by an attach from a
+        different layer.  */
+      lp->stopped = 1;
+    }
 }
 
 static void
This page took 0.025118 seconds and 4 git commands to generate.