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