blob: 87a1353edf71b612c0b201a0e3b11f9b845a9839 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#ifndef WvCIARcg6KvWbOCcoxmM1lc74OI
#define WvCIARcg6KvWbOCcoxmM1lc74OI
#include <assert.h>
#include <signal.h>
volatile bool terminationRequested = false;
void sigIntHandler(int sig) {
terminationRequested = true;
}
void installSigIntHandler() {
struct sigaction action;
action.sa_handler = sigIntHandler;
sigemptyset(&action.sa_mask);
action.sa_flags = 0;
assert(sigaction(SIGINT, &action, NULL) == 0);
}
void sigIntExit() {
// restore old SIG INT handler ...
struct sigaction action;
action.sa_handler = SIG_DFL;
sigemptyset(&action.sa_mask);
action.sa_flags = 0;
assert(sigaction(SIGINT, &action, NULL) == 0);
// ... and use it for suicide
kill(getpid(), SIGINT);
}
#endif // WvCIARcg6KvWbOCcoxmM1lc74OI=
|