2003-07-20 21:58:54 -04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2001-09-09 22:21:46 -04:00
|
|
|
#include <signal.h>
|
|
|
|
|
2003-07-16 15:41:59 -04:00
|
|
|
#include "thread/thread.h"
|
|
|
|
#include "avl/avl.h"
|
|
|
|
#include "httpp/httpp.h"
|
2001-09-09 22:21:46 -04:00
|
|
|
|
|
|
|
#include "global.h"
|
|
|
|
#include "connection.h"
|
|
|
|
#include "refbuf.h"
|
|
|
|
#include "client.h"
|
|
|
|
#include "logging.h"
|
2003-03-05 08:03:35 -05:00
|
|
|
#include "event.h"
|
2001-09-09 22:21:46 -04:00
|
|
|
|
|
|
|
#define CATMODULE "sighandler"
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
void _sig_hup(int signo);
|
|
|
|
void _sig_die(int signo);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void sighandler_initialize(void)
|
|
|
|
{
|
|
|
|
#ifndef _WIN32
|
2003-03-14 21:10:19 -05:00
|
|
|
signal(SIGHUP, _sig_hup);
|
|
|
|
signal(SIGINT, _sig_die);
|
|
|
|
signal(SIGTERM, _sig_die);
|
|
|
|
signal(SIGPIPE, SIG_IGN);
|
2001-09-09 22:21:46 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
|
|
|
void _sig_hup(int signo)
|
|
|
|
{
|
2003-07-25 10:29:33 -04:00
|
|
|
global . schedule_config_reread = 1;
|
2003-03-14 21:10:19 -05:00
|
|
|
/* some OSes require us to reattach the signal handler */
|
|
|
|
signal(SIGHUP, _sig_hup);
|
2001-09-09 22:21:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void _sig_die(int signo)
|
|
|
|
{
|
2003-03-14 21:10:19 -05:00
|
|
|
INFO1("Caught signal %d, shutting down...", signo);
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2003-03-14 21:10:19 -05:00
|
|
|
/* inform the server to start shutting down */
|
|
|
|
global.running = ICE_HALTING;
|
2001-09-09 22:21:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|