author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Thu, 16 Apr 2009 12:50:39 +0200 | |
changeset 72 | 4103c76d5bf2 |
parent 9 | c3fecc82ade6 |
child 77 | 49e0babccb23 |
permissions | -rw-r--r-- |
0 | 1 |
/** |
9
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
2 |
* test/demos/signals.c |
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
3 |
* Copyright (C) 2008 Markus Broeker |
0 | 4 |
*/ |
5 |
||
6 |
#ifndef _XOPEN_SOURCE |
|
7 |
#define _XOPEN_SOURCE 500 |
|
8 |
#endif |
|
9 |
||
10 |
#include <stdio.h> |
|
11 |
#include <stdlib.h> |
|
12 |
#include <signal.h> |
|
13 |
||
14 |
void sigproc () |
|
15 |
{ |
|
16 |
signal (SIGINT, sigproc); |
|
17 |
printf ("I received the SIGINT Signal\n"); |
|
18 |
} |
|
19 |
||
20 |
void sigquit () |
|
21 |
{ |
|
22 |
printf ("I received the SIGQUIT Signal\n"); |
|
23 |
/* |
|
9
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
24 |
* 0 kills every process in the current process group |
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
25 |
* -1 kills all reachable user processes (dangerous, logout) |
0 | 26 |
*/ |
9
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
27 |
kill (0, SIGKILL); |
0 | 28 |
} |
29 |
||
30 |
int main (int argc, char **argv) |
|
31 |
{ |
|
32 |
signal (SIGINT, sigproc); |
|
33 |
signal (SIGQUIT, sigquit); |
|
34 |
||
35 |
printf ("PRESS CTRL-\\ to quit\n"); |
|
36 |
for (;;); |
|
37 |
||
38 |
return EXIT_SUCCESS; |
|
39 |
} |