2003-03-16 14:27:24 +00:00
|
|
|
#include <stdio.h>
|
2020-07-13 19:26:07 +00:00
|
|
|
#include <stdlib.h>
|
2003-03-16 14:27:24 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <signal.h>
|
|
|
|
|
2020-07-13 19:26:07 +00:00
|
|
|
int signalcounter = 0;
|
|
|
|
|
2003-03-16 14:27:24 +00:00
|
|
|
|
|
|
|
void __fastcall__ sighandler (int sig)
|
|
|
|
{
|
|
|
|
printf ("Got signal #%d\n", sig);
|
2020-07-13 19:26:07 +00:00
|
|
|
signalcounter++;
|
2003-03-16 14:27:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main (void)
|
|
|
|
{
|
|
|
|
if (signal (SIGSEGV, sighandler) == SIG_ERR) {
|
|
|
|
printf ("signal failure %d: %s\n", errno, strerror (errno));
|
2020-07-13 19:26:07 +00:00
|
|
|
return EXIT_FAILURE;
|
2003-03-16 14:27:24 +00:00
|
|
|
}
|
|
|
|
printf ("About to raise SIGSEGV...\n");
|
|
|
|
raise (SIGSEGV);
|
|
|
|
printf ("Back from signal handler\n");
|
|
|
|
printf ("About to raise SIGILL...\n");
|
|
|
|
raise (SIGILL);
|
2020-07-13 19:26:07 +00:00
|
|
|
printf ("Back from signal handler, signalcounter = %d\n", signalcounter);
|
|
|
|
if (signalcounter != 1) {
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
return EXIT_SUCCESS;
|
2003-03-16 14:27:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|