2001-09-09 22:21:46 -04:00
|
|
|
#include <signal.h>
|
|
|
|
|
|
|
|
#include "thread.h"
|
|
|
|
#include "avl.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "httpp.h"
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
#include "sighandler.h"
|
|
|
|
|
|
|
|
#define CATMODULE "sighandler"
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
void _sig_hup(int signo);
|
|
|
|
void _sig_die(int signo);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void sighandler_initialize(void)
|
|
|
|
{
|
|
|
|
#ifndef _WIN32
|
|
|
|
signal(SIGHUP, _sig_hup);
|
|
|
|
signal(SIGINT, _sig_die);
|
|
|
|
signal(SIGTERM, _sig_die);
|
|
|
|
signal(SIGPIPE, SIG_IGN);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
|
|
|
void _sig_hup(int signo)
|
|
|
|
{
|
2003-03-05 08:03:35 -05:00
|
|
|
/* We do this elsewhere because it's a bad idea to hang around for too
|
|
|
|
* long re-reading an entire config file inside a signal handler. Bad
|
|
|
|
* practice.
|
|
|
|
*/
|
|
|
|
|
|
|
|
INFO1("Caught signal %d, scheduling config reread ...",
|
|
|
|
signo);
|
2001-09-09 22:21:46 -04:00
|
|
|
|
|
|
|
/* reread config file */
|
|
|
|
|
2003-03-05 08:03:35 -05:00
|
|
|
connection_inject_event(EVENT_CONFIG_READ, NULL);
|
|
|
|
|
|
|
|
/* reopen logfiles (TODO: We don't do this currently) */
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2003-03-05 08:03:35 -05:00
|
|
|
/* some OSes require us to reattach the signal handler */
|
2001-09-09 22:21:46 -04:00
|
|
|
signal(SIGHUP, _sig_hup);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _sig_die(int signo)
|
|
|
|
{
|
|
|
|
INFO1("Caught signal %d, shutting down...", signo);
|
|
|
|
|
|
|
|
/* inform the server to start shutting down */
|
|
|
|
global.running = ICE_HALTING;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|