Port ospf6d to sigevent and rename signal handling functions in vtysh not to

conflict the ones in lib/sigevent.c. Fixes compiling with --disable-shared.
This commit is contained in:
hasso 2004-08-28 17:04:33 +00:00
parent 69f1fc22f7
commit e42f5a3746
4 changed files with 41 additions and 53 deletions

View file

@ -1,3 +1,7 @@
2004-08-28 Hasso Tepper <hasso at quagga.net>
* ospf6_main.c: Modify for sigevents.
2004-08-26 Hasso Tepper <hasso@estpak.ee> 2004-08-26 Hasso Tepper <hasso@estpak.ee>
* ospf6_interface.c, ospf6_top.c, ospf6d.c: for vtysh. * ospf6_interface.c, ospf6_top.c, ospf6d.c: for vtysh.

View file

@ -33,6 +33,7 @@
#include "prefix.h" #include "prefix.h"
#include "plist.h" #include "plist.h"
#include "privs.h" #include "privs.h"
#include "sigevent.h"
#include "ospf6d.h" #include "ospf6d.h"
@ -119,14 +120,14 @@ Report bugs to zebra@zebra.org\n", progname);
/* SIGHUP handler. */ /* SIGHUP handler. */
void void
sighup (int sig) sighup (void)
{ {
zlog_info ("SIGHUP received"); zlog_info ("SIGHUP received");
} }
/* SIGINT handler. */ /* SIGINT handler. */
void void
sigint (int sig) sigint (void)
{ {
zlog_info ("SIGINT received"); zlog_info ("SIGINT received");
exit (0); exit (0);
@ -134,7 +135,7 @@ sigint (int sig)
/* SIGTERM handler. */ /* SIGTERM handler. */
void void
sigterm (int sig) sigterm (void)
{ {
zlog_info ("SIGTERM received"); zlog_info ("SIGTERM received");
exit (0); exit (0);
@ -142,54 +143,31 @@ sigterm (int sig)
/* SIGUSR1 handler. */ /* SIGUSR1 handler. */
void void
sigusr1 (int sig) sigusr1 (void)
{ {
zlog_info ("SIGUSR1 received"); zlog_info ("SIGUSR1 received");
zlog_rotate (NULL); zlog_rotate (NULL);
} }
/* Signale wrapper. */ struct quagga_signal_t ospf6_signals[] =
RETSIGTYPE *
signal_set (int signo, void (*func)(int))
{ {
int ret; {
struct sigaction sig; .signal = SIGHUP,
struct sigaction osig; .handler = &sighup,
},
sig.sa_handler = func; {
sigemptyset (&sig.sa_mask); .signal = SIGINT,
sig.sa_flags = 0; .handler = &sigint,
#ifdef SA_RESTART },
sig.sa_flags |= SA_RESTART; {
#endif /* SA_RESTART */ .signal = SIGTERM,
.handler = &sigterm,
ret = sigaction (signo, &sig, &osig); },
{
if (ret < 0) .signal = SIGUSR1,
return (SIG_ERR); .handler = &sigusr1,
else },
return (osig.sa_handler); };
}
/* Initialization of signal handles. */
void
signal_init ()
{
signal_set (SIGHUP, sighup);
signal_set (SIGINT, sigint);
signal_set (SIGTERM, sigterm);
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);
}
/* Main routine of ospf6d. Treatment of argument and starting ospf finite /* Main routine of ospf6d. Treatment of argument and starting ospf finite
state machine is handled here. */ state machine is handled here. */
@ -275,7 +253,7 @@ main (int argc, char *argv[], char *envp[])
LOG_DAEMON); LOG_DAEMON);
zprivs_init (&ospf6d_privs); zprivs_init (&ospf6d_privs);
/* initialize zebra libraries */ /* initialize zebra libraries */
signal_init (); signal_init (master, Q_SIGC(ospf6_signals), ospf6_signals);
cmd_init (1); cmd_init (1);
vty_init (master); vty_init (master);
memory_init (); memory_init ();

View file

@ -1,3 +1,8 @@
2004-08-28 Hasso Tepper <hasso at quagga.net>
* vtysh_main.c: Rename signal handling functions not to conflict
with functions from lib/sigevent.c.
2004-08-27 Hasso Tepper <hasso at quagga.net> 2004-08-27 Hasso Tepper <hasso at quagga.net>
* vtysh.c: Make "terminal length <0-512>" command work in vtysh. * vtysh.c: Make "terminal length <0-512>" command work in vtysh.

View file

@ -99,9 +99,10 @@ sigint (int sig)
} }
} }
/* Signale wrapper. */ /* Signale wrapper for vtysh. We don't use sigevent because
* vtysh doesn't use threads. TODO */
RETSIGTYPE * RETSIGTYPE *
signal_set (int signo, void (*func)(int)) vtysh_signal_set (int signo, void (*func)(int))
{ {
int ret; int ret;
struct sigaction sig; struct sigaction sig;
@ -124,11 +125,11 @@ signal_set (int signo, void (*func)(int))
/* Initialization of signal handles. */ /* Initialization of signal handles. */
void void
signal_init () vtysh_signal_init ()
{ {
signal_set (SIGINT, sigint); vtysh_signal_set (SIGINT, sigint);
signal_set (SIGTSTP, sigtstp); vtysh_signal_set (SIGTSTP, sigtstp);
signal_set (SIGPIPE, SIG_IGN); vtysh_signal_set (SIGPIPE, SIG_IGN);
} }
/* Help information display. */ /* Help information display. */
@ -243,7 +244,7 @@ main (int argc, char **argv, char **env)
line_read = NULL; line_read = NULL;
/* Signal and others. */ /* Signal and others. */
signal_init (); vtysh_signal_init ();
/* Make vty structure and register commands. */ /* Make vty structure and register commands. */
vtysh_init_vty (); vtysh_init_vty ();