Blob Blame History Raw
Index: gdb-6.3/gdb/linux-nat.c
===================================================================
--- gdb-6.3.orig/gdb/linux-nat.c	2006-06-15 07:27:02.000000000 -0300
+++ gdb-6.3/gdb/linux-nat.c	2006-06-15 07:27:06.000000000 -0300
@@ -157,12 +157,28 @@ static int
 my_waitpid (int pid, int *status, int flags)
 {
   int ret;
+  int old_status = status ? *status : 0;
+
   do
     {
       ret = waitpid (pid, status, flags);
     }
   while (ret == -1 && errno == EINTR);
 
+  if (ret == 0 && status != 0)
+    {
+      /* waitpid() running within ia32el (on multi-threaded processes
+	 only?) modifies status even when it returns zero, and this
+	 breaks the assumption in linux_nat_wait(), and perhaps
+	 elsewhere, that it remains unchanged in this case.  We
+	 restore the old value before returning zero, such that the
+	 assumption holds.  */
+      if (*status != 0 && *status != old_status)
+        warning ("waitpid: non-zero status %x for zero return value",
+                 *status);
+      *status = old_status;
+    }
+
   return ret;
 }