diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-06-04 11:38:17 +0200 |
---|---|---|
committer | Daniel Borkmann <dborkman@redhat.com> | 2013-06-04 11:38:17 +0200 |
commit | 57968a8ab19b45b5d128656f6bed2581aee2ef22 (patch) | |
tree | 48e9c560f6f9ffab29debf2cffaaad1acd331c55 | |
parent | ab9d73629872a474d9194177fa4c9c8cdabe9a44 (diff) |
sig: add signal handling functions
Add an extra file for signal handling functions.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
-rw-r--r-- | astraceroute.c | 1 | ||||
-rw-r--r-- | astraceroute/Makefile | 1 | ||||
-rw-r--r-- | curvetun.c | 1 | ||||
-rw-r--r-- | curvetun/Makefile | 1 | ||||
-rw-r--r-- | flowtop.c | 1 | ||||
-rw-r--r-- | flowtop/Makefile | 1 | ||||
-rw-r--r-- | ifpps.c | 1 | ||||
-rw-r--r-- | ifpps/Makefile | 2 | ||||
-rw-r--r-- | netsniff-ng.c | 1 | ||||
-rw-r--r-- | netsniff-ng/Makefile | 1 | ||||
-rw-r--r-- | sig.c | 32 | ||||
-rw-r--r-- | sig.h | 7 | ||||
-rw-r--r-- | trafgen.c | 1 | ||||
-rw-r--r-- | trafgen/Makefile | 1 | ||||
-rw-r--r-- | xutils.c | 28 | ||||
-rw-r--r-- | xutils.h | 2 |
16 files changed, 52 insertions, 30 deletions
diff --git a/astraceroute.c b/astraceroute.c index 1469f8f..a7f04c6 100644 --- a/astraceroute.c +++ b/astraceroute.c @@ -34,6 +34,7 @@ #include "bpf.h" #include "die.h" #include "dev.h" +#include "sig.h" #include "tprintf.h" #include "pkt_buff.h" #include "proto.h" diff --git a/astraceroute/Makefile b/astraceroute/Makefile index ba45395..b99e310 100644 --- a/astraceroute/Makefile +++ b/astraceroute/Makefile @@ -9,6 +9,7 @@ astraceroute-objs = xmalloc.o \ tprintf.o \ bpf.o \ str.o \ + sig.o \ sock.o \ link.o \ dev.o \ @@ -28,6 +28,7 @@ #include "xutils.h" #include "die.h" #include "str.h" +#include "sig.h" #include "cookie.h" #include "ioexact.h" #include "xmalloc.h" diff --git a/curvetun/Makefile b/curvetun/Makefile index 111664c..f66fd4d 100644 --- a/curvetun/Makefile +++ b/curvetun/Makefile @@ -7,6 +7,7 @@ curvetun-objs = xmalloc.o \ dev.o \ stun.o \ sock.o \ + sig.o \ link.o \ patricia.o \ corking.o \ @@ -31,6 +31,7 @@ #include "xmalloc.h" #include "ioops.h" #include "str.h" +#include "sig.h" #include "geoip.h" #include "xutils.h" #include "built_in.h" diff --git a/flowtop/Makefile b/flowtop/Makefile index ba22803..43f221f 100644 --- a/flowtop/Makefile +++ b/flowtop/Makefile @@ -10,6 +10,7 @@ flowtop-objs = xmalloc.o \ xutils.o \ oui.o \ str.o \ + sig.o \ sock.o \ dev.o \ link.o \ @@ -19,6 +19,7 @@ #include "die.h" #include "dev.h" +#include "sig.h" #include "link.h" #include "xmalloc.h" #include "xutils.h" diff --git a/ifpps/Makefile b/ifpps/Makefile index 6088ec6..6f2666f 100644 --- a/ifpps/Makefile +++ b/ifpps/Makefile @@ -5,5 +5,7 @@ ifpps-objs = xmalloc.o \ promisc.o \ str.o \ link.o \ + sock.o \ dev.o \ + sig.o \ ifpps.o diff --git a/netsniff-ng.c b/netsniff-ng.c index 9eb482d..65875d8 100644 --- a/netsniff-ng.c +++ b/netsniff-ng.c @@ -37,6 +37,7 @@ #include "die.h" #include "irq.h" #include "str.h" +#include "sig.h" #include "sock.h" #include "geoip.h" #include "lockme.h" diff --git a/netsniff-ng/Makefile b/netsniff-ng/Makefile index 02c6120..cbe8f64 100644 --- a/netsniff-ng/Makefile +++ b/netsniff-ng/Makefile @@ -37,6 +37,7 @@ netsniff-ng-objs = dissector.o \ proc.o \ dev.o \ str.o \ + sig.o \ sock.o \ irq.o \ iosched.o \ @@ -0,0 +1,32 @@ +#include <stdio.h> +#include <signal.h> + +#include "sig.h" + +void register_signal(int signal, void (*handler)(int)) +{ + sigset_t block_mask; + struct sigaction saction; + + sigfillset(&block_mask); + + saction.sa_handler = handler; + saction.sa_mask = block_mask; + saction.sa_flags = SA_RESTART; + + sigaction(signal, &saction, NULL); +} + +void register_signal_f(int signal, void (*handler)(int), int flags) +{ + sigset_t block_mask; + struct sigaction saction; + + sigfillset(&block_mask); + + saction.sa_handler = handler; + saction.sa_mask = block_mask; + saction.sa_flags = flags; + + sigaction(signal, &saction, NULL); +} @@ -0,0 +1,7 @@ +#ifndef SIG_H +#define SIG_H + +extern void register_signal(int signal, void (*handler)(int)); +extern void register_signal_f(int signal, void (*handler)(int), int flags); + +#endif /* SIG_H */ @@ -35,6 +35,7 @@ #include "xmalloc.h" #include "die.h" #include "str.h" +#include "sig.h" #include "sock.h" #include "cpus.h" #include "lockme.h" diff --git a/trafgen/Makefile b/trafgen/Makefile index 69db433..5aeb424 100644 --- a/trafgen/Makefile +++ b/trafgen/Makefile @@ -11,6 +11,7 @@ trafgen-objs = xmalloc.o \ irq.o \ link.o \ str.o \ + sig.o \ sock.o \ mac80211.o \ ring_tx.o \ @@ -72,34 +72,6 @@ int set_epoll_descriptor2(int fd_epoll, int action, int fd_toadd, int events) return epoll_ctl(fd_epoll, action, fd_toadd, &ev); } -void register_signal(int signal, void (*handler)(int)) -{ - sigset_t block_mask; - struct sigaction saction; - - sigfillset(&block_mask); - - saction.sa_handler = handler; - saction.sa_mask = block_mask; - saction.sa_flags = SA_RESTART; - - sigaction(signal, &saction, NULL); -} - -void register_signal_f(int signal, void (*handler)(int), int flags) -{ - sigset_t block_mask; - struct sigaction saction; - - sigfillset(&block_mask); - - saction.sa_handler = handler; - saction.sa_mask = block_mask; - saction.sa_flags = flags; - - sigaction(signal, &saction, NULL); -} - void set_itimer_interval_value(struct itimerval *itimer, unsigned long sec, unsigned long usec) { @@ -25,8 +25,6 @@ #include "built_in.h" -extern void register_signal(int signal, void (*handler)(int)); -extern void register_signal_f(int signal, void (*handler)(int), int flags); extern void set_epoll_descriptor(int fd_epoll, int action, int fd_toadd, int events); extern int set_epoll_descriptor2(int fd_epoll, int action, int fd_toadd, int events); extern void set_itimer_interval_value(struct itimerval *itimer, unsigned long sec, |