#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. */
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