author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Fri, 27 Dec 2013 16:00:09 +0100 | |
changeset 167 | 7c6b221900bf |
parent 77 | 49e0babccb23 |
permissions | -rw-r--r-- |
0 | 1 |
/** |
77 | 2 |
* signals.c |
9
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 |
} |