xsys: renamed netdev.c/h to xsys.c/h to further reduce other files
[netsniff-ng.git] / src / signals.h
blob461a71b7cc951fa98314c0a641dcaa2f0ea0f839
1 /*
2 * netsniff-ng - the packet sniffing beast
3 * By Daniel Borkmann <daniel@netsniff-ng.org>
4 * Copyright 2009, 2010 Daniel Borkmann.
5 * Subject to the GPL, version 2.
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 */