static void
sigterm_handler(int sig)
{
- /* XXX we had a flush_connections() here - we should close all the
- * connections and flush data. read server_reboot() for my explanation.
- * -- adrian
- */
- ilog(L_MAIN, "Server killed By SIGTERM");
- exit(-1);
+ ircd_shutdown("Received SIGTERM");
}
/*
void
setup_signals()
{
+ sigset_t sigs;
struct sigaction act;
+ sigemptyset(&sigs);
act.sa_flags = 0;
act.sa_handler = SIG_IGN;
sigemptyset(&act.sa_mask);
act.sa_handler = dummy_handler;
sigaction(SIGALRM, &act, 0);
+ sigaddset(&sigs, SIGALRM);
act.sa_handler = sighup_handler;
sigemptyset(&act.sa_mask);
sigaddset(&act.sa_mask, SIGHUP);
sigaction(SIGHUP, &act, 0);
+ sigaddset(&sigs, SIGHUP);
act.sa_handler = sigint_handler;
sigaddset(&act.sa_mask, SIGINT);
sigaction(SIGINT, &act, 0);
+ sigaddset(&sigs, SIGINT);
act.sa_handler = sigterm_handler;
sigaddset(&act.sa_mask, SIGTERM);
sigaction(SIGTERM, &act, 0);
+ sigaddset(&sigs, SIGTERM);
act.sa_handler = sigusr1_handler;
sigaddset(&act.sa_mask, SIGUSR1);
sigaction(SIGUSR1, &act, 0);
+ sigaddset(&sigs, SIGUSR1);
act.sa_handler = sigusr2_handler;
sigaddset(&act.sa_mask, SIGUSR2);
sigaction(SIGUSR2, &act, 0);
+ sigaddset(&sigs, SIGUSR2);
act.sa_handler = sigchld_handler;
sigaddset(&act.sa_mask, SIGCHLD);
sigaction(SIGCHLD, &act, 0);
+ sigaddset(&sigs, SIGCHLD);
+ sigprocmask(SIG_UNBLOCK, &sigs, NULL);
}