| 1 | #include <signal.h> |
|---|
| 2 | #include <Errors.h> |
|---|
| 3 | |
|---|
| 4 | void |
|---|
| 5 | my_signal_handler(int sig, char *userData, vregs regs) |
|---|
| 6 | { |
|---|
| 7 | printf("%d\n", sig); |
|---|
| 8 | } |
|---|
| 9 | |
|---|
| 10 | int 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 | } |
|---|