1 | |
---|
2 | #include <stdio.h> |
---|
3 | |
---|
4 | #define INCL_DOS |
---|
5 | #include <os2.h> |
---|
6 | #define INCL_LOADEXCEPTQ |
---|
7 | #include "exceptq.h" |
---|
8 | |
---|
9 | |
---|
10 | void main(void) |
---|
11 | { |
---|
12 | int a=1, b=0; |
---|
13 | int pid; |
---|
14 | int status; |
---|
15 | |
---|
16 | EXCEPTIONREGISTRATIONRECORD exRegRec; |
---|
17 | LoadExceptq(&exRegRec, ""); |
---|
18 | |
---|
19 | printf("loaded\n"); |
---|
20 | pid = fork(); |
---|
21 | printf("forked %d\n", pid); |
---|
22 | if (pid == 0) { |
---|
23 | // uncomment to trap excetion |
---|
24 | // EXCEPTIONREGISTRATIONRECORD exRegRecC; |
---|
25 | // LoadExceptqAlways(&exRegRecC, ""); |
---|
26 | printf("forked child pid %d\n", getpid()); |
---|
27 | |
---|
28 | // crashme |
---|
29 | printf("crash %d\n", a/b); |
---|
30 | |
---|
31 | // uncomment to trap excetion |
---|
32 | // UninstallExceptq(&exRegRecC); |
---|
33 | } |
---|
34 | wait(&status); |
---|
35 | |
---|
36 | // uncomment this to get TWO (if above enabled) exception reports, one for parent one for child. |
---|
37 | // printf("crash %d\n", a/b); |
---|
38 | |
---|
39 | UninstallExceptq(&exRegRec); |
---|
40 | printf("unloaded\n"); |
---|
41 | } |
---|
42 | |
---|