equal
deleted
inserted
replaced
|
1 /** |
|
2 * $Id: signals.c,v 1.1.1.1 2008-04-28 17:32:53 mbroeker Exp $ |
|
3 * $Source: /development/c/demos/signals.c,v $ |
|
4 * |
|
5 */ |
|
6 |
|
7 #ifndef _XOPEN_SOURCE |
|
8 #define _XOPEN_SOURCE 500 |
|
9 #endif |
|
10 |
|
11 #include <stdio.h> |
|
12 #include <stdlib.h> |
|
13 #include <signal.h> |
|
14 |
|
15 void sigproc () |
|
16 { |
|
17 signal (SIGINT, sigproc); |
|
18 printf ("I received the SIGINT Signal\n"); |
|
19 } |
|
20 |
|
21 void sigquit () |
|
22 { |
|
23 printf ("I received the SIGQUIT Signal\n"); |
|
24 /* |
|
25 * This kills the process and subprocesses |
|
26 */ |
|
27 kill (-1, SIGKILL); |
|
28 /* |
|
29 * ^^ can not be reached |
|
30 */ |
|
31 exit (0); |
|
32 } |
|
33 |
|
34 int main (int argc, char **argv) |
|
35 { |
|
36 signal (SIGINT, sigproc); |
|
37 signal (SIGQUIT, sigquit); |
|
38 |
|
39 printf ("PRESS CTRL-\\ to quit\n"); |
|
40 for (;;); |
|
41 |
|
42 return EXIT_SUCCESS; |
|
43 } |