]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/testsuite/gdb.threads/process-dies-while-detaching.c
Fix gdb.threads/process-dies-while-detaching.exp
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.threads / process-dies-while-detaching.c
index eecaaedb3d9c40044374a91f87e9c9520c222948..4ba50d40aff5f896471a53f2c37f70309afad436 100644 (file)
@@ -22,6 +22,8 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <assert.h>
+#include <errno.h>
+#include <string.h>
 
 /* This barrier ensures we only reach the initial breakpoint after all
    threads have started.  */
@@ -78,15 +80,27 @@ parent_function (pid_t child)
   alarm (300);
 
   ret = waitpid (child, &status, 0);
+
   if (ret == -1)
-    exit (1);
-  else if (!WIFEXITED (status))
-    exit (2);
-  else
+    {
+      printf ("waitpid, errno=%d (%s)\n", errno, strerror (errno));
+      exit (1);
+    }
+  else if (WIFEXITED (status))
     {
       printf ("exited, status=%d\n", WEXITSTATUS (status));
       exit (0);
     }
+  else if (WIFSIGNALED (status))
+    {
+      printf ("signaled, sig=%d\n", WTERMSIG (status));
+      exit (2);
+    }
+  else
+    {
+      printf ("unexpected, status=%x\n", status);
+      exit (3);
+    }
 }
 
 #endif