Fixed demo program, now working
[ana-net.git] / app / signals.h
blobf8780f2682f80ea5dc0740f4fc73ad6e70398726
1 /*
2 * Lightweight Autonomic Network Architecture
3 * Copyright 2011 Daniel Borkmann <dborkma@tik.ee.ethz.ch>,
4 * Swiss federal institute of technology (ETH Zurich)
5 * Subject to the GPL.
6 */
8 #ifndef SIGNALS_H
9 #define SIGNALS_H
11 #include <signal.h>
12 #include <assert.h>
14 static inline void register_signal(int signal, void (*handler)(int))
16 sigset_t block_mask;
17 struct sigaction saction;
19 assert(handler);
21 sigfillset(&block_mask);
22 saction.sa_handler = handler;
23 saction.sa_mask = block_mask;
24 saction.sa_flags = SA_RESTART;
26 sigaction(signal, &saction, NULL);
29 static inline void register_signal_f(int signal, void (*handler)(int),
30 int flags)
32 sigset_t block_mask;
33 struct sigaction saction;
35 assert(handler);
37 sigfillset(&block_mask);
38 saction.sa_handler = handler;
39 saction.sa_mask = block_mask;
40 saction.sa_flags = flags;
42 sigaction(signal, &saction, NULL);
45 #endif /* SIGNALS_H */