]>
Commit | Line | Data |
---|---|---|
075559bc AC |
1 | #include <signal.h> |
2 | #include <unistd.h> | |
3 | #include <stdlib.h> | |
4 | ||
5 | void foo (void); | |
6 | void bar (void); | |
7 | ||
8 | void subroutine (int); | |
9 | void handler (int); | |
10 | void have_a_very_merry_interrupt (void); | |
11 | ||
12 | main () | |
13 | { | |
14 | puts ("Starting up"); | |
15 | ||
16 | foo (); /* Put a breakpoint on foo() and call it to see a dummy frame */ | |
17 | ||
18 | ||
19 | have_a_very_merry_interrupt (); | |
20 | ||
21 | puts ("Shutting down"); | |
22 | } | |
23 | ||
24 | void | |
25 | foo (void) | |
26 | { | |
27 | puts ("hi in foo"); | |
28 | } | |
29 | ||
30 | void | |
31 | bar (void) | |
32 | { | |
33 | char *nuller = 0; | |
34 | ||
35 | puts ("hi in bar"); | |
36 | ||
37 | *nuller = 'a'; /* try to cause a segfault */ | |
38 | } | |
39 | ||
40 | void | |
41 | handler (int sig) | |
42 | { | |
43 | subroutine (sig); | |
44 | } | |
45 | ||
46 | void | |
47 | subroutine (int in) | |
48 | { | |
5d0331e5 JM |
49 | int count = in; |
50 | while (count < 100) | |
51 | count++; | |
075559bc AC |
52 | } |
53 | ||
54 | void | |
55 | have_a_very_merry_interrupt (void) | |
56 | { | |
57 | puts ("Waiting to get a signal"); | |
58 | signal (SIGALRM, handler); | |
59 | alarm (1); | |
60 | sleep (2); /* We'll receive that signal while sleeping */ | |
61 | } | |
62 |