#include <sched.h>
#include <signal.h>
+#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
}
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)
{
}
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)
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");