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.
diff --git a/zebra/main.c b/zebra/main.c
index 98227ea..a66734c 100644
--- a/zebra/main.c
+++ b/zebra/main.c
@@ -30,6 +30,7 @@
#include "prefix.h"
#include "log.h"
#include "privs.h"
+#include "sigevent.h"
#include "zebra/rib.h"
#include "zebra/zserv.h"
@@ -131,7 +132,7 @@
/* SIGHUP handler. */
void
-sighup (int sig)
+sighup (void)
{
zlog_info ("SIGHUP received");
@@ -141,7 +142,7 @@
/* SIGINT handler. */
void
-sigint (int sig)
+sigint (void)
{
/* Decrared in rib.c */
void rib_close ();
@@ -156,44 +157,26 @@
/* SIGUSR1 handler. */
void
-sigusr1 (int sig)
+sigusr1 (void)
{
zlog_rotate (NULL);
}
-/* Signale wrapper. */
-RETSIGTYPE *
-signal_set (int signo, void (*func)(int))
+struct quagga_signal_t zebra_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);
- signal_set (SIGUSR1, sigusr1);
-}
+ {
+ .signal = SIGHUP,
+ .handler = &sighup,
+ },
+ {
+ .signal = SIGUSR1,
+ .handler = &sigusr1,
+ },
+ {
+ .signal = SIGINT,
+ .handler = &sigusr1,
+ },
+};
/* Main startup routine. */
int
@@ -289,7 +272,7 @@
zprivs_init (&zserv_privs);
/* Vty related initialize. */
- signal_init ();
+ signal_init (zebrad.master, Q_SIGC(zebra_signals), zebra_signals);
cmd_init (1);
vty_init (zebrad.master);
memory_init ();