newlib/winsup/testsuite/winsup.api/resethand.c
Christopher Faylor 7f9832e774 * cygload/README: Delete.
* cygload/cygload.cc: Move to winsup.api.  Add comments from README.
* cygload/cygload.h: Move to winsup.api.
* cygload/cygload.exp: Move to winsup.api.
* Makefile.in: Remove cygload.
* winsup.api/winsup.exp: If a .exp file is detected, run it rather than using
standard compile.
* winsup.api/resethand.c (main): Use printf to print status or expect thinks
something is wrong.
2006-01-02 06:15:58 +00:00

37 lines
696 B
C

#include <stdio.h>
#include <signal.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
int doit = 0;
void
ouch (int sig)
{
if (doit++ > 0)
kill (getpid (), SIGTERM);
}
int
main (int argc, char **argv)
{
static struct sigaction act;
if (argc == 1)
act.sa_flags = SA_RESETHAND;
act.sa_handler = ouch;
sigaction (SIGSEGV, &act, NULL);
int pid = fork ();
int status;
if (pid > 0)
waitpid (pid, &status, 0);
else
{
int *i = 0;
*i = 9;
exit (0x42);
}
status &= ~0x80; // remove core dump flag
printf ("pid %d exited with status %p\n", pid, (void *) status);
exit (argc == 1 ? !(status == SIGSEGV) : !(status == SIGTERM));
}