-RETSIGTYPE
-sigterm_handler(int a)
-{
- if(debug_lvl > DEBUG_NOTHING)
- syslog(LOG_NOTICE, _("Got TERM signal"));
-
- cleanup_and_exit(0);
-}
-
-RETSIGTYPE
-sigquit_handler(int a)
-{
- if(debug_lvl > DEBUG_NOTHING)
- syslog(LOG_NOTICE, _("Got QUIT signal"));
- cleanup_and_exit(0);
-}
-
-RETSIGTYPE
-sigsegv_square(int a)
-{
- syslog(LOG_ERR, _("Got another SEGV signal: not restarting"));
- exit(0);
-}
-
-RETSIGTYPE
-sigsegv_handler(int a)
-{
- syslog(LOG_ERR, _("Got SEGV signal"));
- cp_trace();
-
- if(do_detach)
- {
- syslog(LOG_NOTICE, _("Trying to re-execute in 5 seconds..."));
- signal(SIGSEGV, sigsegv_square);
- close_network_connections();
- sleep(5);
- remove_pid(pidfilename);
- execvp(g_argv[0], g_argv);
- }
- else
- {
- syslog(LOG_NOTICE, _("Not restarting."));
- exit(0);
- }
-}
-
-RETSIGTYPE
-sighup_handler(int a)
-{
- if(debug_lvl > DEBUG_NOTHING)
- syslog(LOG_NOTICE, _("Got HUP signal"));
- sighup = 1;
-}
-
-RETSIGTYPE
-sigint_handler(int a)
-{
- if(debug_lvl > DEBUG_NOTHING)
- syslog(LOG_NOTICE, _("Got INT signal, exiting"));
- cleanup_and_exit(0);
-}
-
-RETSIGTYPE
-sigusr1_handler(int a)
-{
- dump_conn_list();
-}
-
-RETSIGTYPE
-sigusr2_handler(int a)
-{
- dump_subnet_list();
-}
-
-RETSIGTYPE
-sighuh(int a)
-{
- syslog(LOG_WARNING, _("Got unexpected signal %d (%s)"), a, strsignal(a));
- cp_trace();
-}
-
-void
-setup_signals(void)
-{
- int i;
-
- for(i=0;i<32;i++)
- signal(i,sighuh);
-
- if(signal(SIGTERM, SIG_IGN) != SIG_ERR)
- signal(SIGTERM, sigterm_handler);
- if(signal(SIGQUIT, SIG_IGN) != SIG_ERR)
- signal(SIGQUIT, sigquit_handler);
- if(signal(SIGSEGV, SIG_IGN) != SIG_ERR)
- signal(SIGSEGV, sigsegv_handler);
- if(signal(SIGHUP, SIG_IGN) != SIG_ERR)
- signal(SIGHUP, sighup_handler);
- signal(SIGPIPE, SIG_IGN);
- if(signal(SIGINT, SIG_IGN) != SIG_ERR)
- signal(SIGINT, sigint_handler);
- signal(SIGUSR1, sigusr1_handler);
- signal(SIGUSR2, sigusr2_handler);
- signal(SIGCHLD, SIG_IGN);
-}
-
-RETSIGTYPE parent_exit(int a)
-{
- exit(0);
-}