Ticket #3265: test_custom_signal_handling.c

File test_custom_signal_handling.c, 568 bytes (added by oco, 16 years ago)
Line 
1#include <signal.h>
2#include <Errors.h>
3
4void
5my_signal_handler(int sig, char *userData, vregs regs)
6{
7 printf("%d\n", sig);
8}
9
10int main()
11{
12 struct sigaction sa;
13 char data_buffer[32];
14 int a = 10;
15 int b = 0;
16 int c = 0;
17
18 sa.sa_handler = (sighandler_t)my_signal_handler;
19 sigemptyset(&sa.sa_mask);
20 sa.sa_userdata = NULL;
21
22 if (sigaction(SIGSEGV, &sa, NULL) != B_OK)
23 {
24 printf("sigaction error\n");
25 };
26 if (sigaction(SIGFPE, &sa, NULL) != B_OK)
27 {
28 printf("sigaction error\n");
29 };
30 printf("Before calc...\n");
31 c = a / b;
32 printf("Hello\n");
33 return 0;
34}