diff options
author | paul <paul> | 2004-01-19 21:31:15 +0000 |
---|---|---|
committer | paul <paul> | 2004-01-19 21:31:15 +0000 |
commit | 2d75d05218b76230bbd608cab8d08a5f47d77056 (patch) | |
tree | 7087570a7dbb8b650349b98a8f1963dfdcedceb1 /ospfd/ospf_main.c | |
parent | 9a76e2ddb6c4dc303ce7ed937c0cfa9430c3ed27 (diff) |
2004-01-19 Paul Jakma <paul@dishone.st>
* tests/test-sig.c: New file, regression test for sigevents.
* lib/Makefile.am: add sigevent.{c,h}
* (isis|rip|ripng|ospf|ospf6|bgp)d/\1_main.c: modify for sigevents.
* zebra/main.c: ditto.
Diffstat (limited to 'ospfd/ospf_main.c')
-rw-r--r-- | ospfd/ospf_main.c | 69 |
1 files changed, 19 insertions, 50 deletions
diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c index 51fa7b58..3f1e4fda 100644 --- a/ospfd/ospf_main.c +++ b/ospfd/ospf_main.c @@ -38,6 +38,7 @@ #include "memory.h" #include "privs.h" #include "debug.h" +#include "sigevent.h" #include "ospfd/ospfd.h" #include "ospfd/ospf_interface.h" @@ -125,14 +126,14 @@ Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); /* SIGHUP handler. */ void -sighup (int sig) +sighup (void) { zlog (NULL, LOG_INFO, "SIGHUP received"); } /* SIGINT handler. */ void -sigint (int sig) +sigint (void) { zlog (NULL, LOG_INFO, "Terminating on signal"); @@ -143,58 +144,26 @@ sigint (int sig) /* SIGUSR1 handler. */ void -sigusr1 (int sig) +sigusr1 (void) { zlog_rotate (NULL); } -/* Signal wrapper. */ -RETSIGTYPE * -signal_set (int signo, void (*func)(int)) +struct quagga_signal_t ospf_signals[] = { - int ret; - struct sigaction sig; - struct sigaction osig; - - sig.sa_handler = func; - sigemptyset (&sig.sa_mask); - sig.sa_flags = 0; -#ifdef SA_RESTART - sig.sa_flags |= SA_RESTART; -#endif /* SA_RESTART */ - - ret = sigaction (signo, &sig, &osig); - - if (ret < 0) - return (SIG_ERR); - else - return (osig.sa_handler); -} - -/* Initialization of signal handles. */ -void -signal_init () -{ - signal_set (SIGHUP, sighup); - signal_set (SIGINT, sigint); - signal_set (SIGTERM, sigint); - signal_set (SIGPIPE, SIG_IGN); -#ifdef SIGTSTP - signal_set (SIGTSTP, SIG_IGN); -#endif -#ifdef SIGTTIN - signal_set (SIGTTIN, SIG_IGN); -#endif -#ifdef SIGTTOU - signal_set (SIGTTOU, SIG_IGN); -#endif - signal_set (SIGUSR1, sigusr1); -#ifdef HAVE_GLIBC_BACKTRACE - signal_set (SIGBUS, debug_print_trace); - signal_set (SIGSEGV, debug_print_trace); - signal_set (SIGILL, debug_print_trace); -#endif /* HAVE_GLIBC_BACKTRACE */ -} + { + .signal = SIGHUP, + .handler = &sighup, + }, + { + .signal = SIGUSR1, + .handler = &sigusr1, + }, + { + .signal = SIGINT, + .handler = &sigint, + }, +}; /* OSPFd main routine. */ int @@ -285,7 +254,7 @@ main (int argc, char **argv) /* Library inits. */ zprivs_init (&ospfd_privs); - signal_init (); + signal_init (master, Q_SIGC(ospf_signals), ospf_signals); cmd_init (1); debug_init (); vty_init (master); |