Skip to content

Commit

Permalink
If child crashes, report this first. Print which signal.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrich Drepper committed Dec 15, 2004
1 parent a2f63c5 commit 8a3f584
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions nptl/tst-getpid1.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <sched.h>
#include <signal.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
Expand Down Expand Up @@ -66,20 +67,6 @@ do_test (void)
}
while (si.si_signo != sig || si.si_code != SI_QUEUE);

if (si.si_int != (int) p)
{
printf ("expected PID %d, got si_int %d\n", (int) p, si.si_int);
kill (p, SIGKILL);
return 1;
}

if (si.si_pid != p)
{
printf ("expected PID %d, got si_pid %d\n", (int) p, (int) si.si_pid);
kill (p, SIGKILL);
return 1;
}

int e;
if (waitpid (p, &e, __WCLONE) != p)
{
Expand All @@ -89,7 +76,10 @@ do_test (void)
}
if (!WIFEXITED (e))
{
puts ("did not terminate correctly");
if (WIFSIGNALED (e))
printf ("died from signal %s\n", strsignal (WTERMSIG (e)));
else
puts ("did not terminate correctly");
return 1;
}
if (WEXITSTATUS (e) != 0)
Expand All @@ -98,6 +88,20 @@ do_test (void)
return 1;
}

if (si.si_int != (int) p)
{
printf ("expected PID %d, got si_int %d\n", (int) p, si.si_int);
kill (p, SIGKILL);
return 1;
}

if (si.si_pid != p)
{
printf ("expected PID %d, got si_pid %d\n", (int) p, (int) si.si_pid);
kill (p, SIGKILL);
return 1;
}

if (getpid () != mypid)
{
puts ("my PID changed");
Expand Down

0 comments on commit 8a3f584

Please sign in to comment.