sighandler.c 915 Bytes
Newer Older
1 2 3 4
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

Jack Moffitt's avatar
Jack Moffitt committed
5 6
#include <signal.h>

Karl Heyes's avatar
Karl Heyes committed
7 8 9
#include "thread/thread.h"
#include "avl/avl.h"
#include "httpp/httpp.h"
Jack Moffitt's avatar
Jack Moffitt committed
10 11 12 13 14 15

#include "global.h"
#include "connection.h"
#include "refbuf.h"
#include "client.h"
#include "logging.h"
16
#include "event.h"
Jack Moffitt's avatar
Jack Moffitt committed
17 18 19 20 21 22 23 24 25 26 27

#define CATMODULE "sighandler"

#ifndef _WIN32
void _sig_hup(int signo);
void _sig_die(int signo);
#endif

void sighandler_initialize(void)
{
#ifndef _WIN32
28 29 30 31
    signal(SIGHUP, _sig_hup);
    signal(SIGINT, _sig_die);
    signal(SIGTERM, _sig_die);
    signal(SIGPIPE, SIG_IGN);
Jack Moffitt's avatar
Jack Moffitt committed
32 33 34 35 36 37 38
#endif
}

#ifndef _WIN32

void _sig_hup(int signo)
{
39
    global . schedule_config_reread = 1;
40 41
    /* some OSes require us to reattach the signal handler */
    signal(SIGHUP, _sig_hup);
Jack Moffitt's avatar
Jack Moffitt committed
42 43 44 45
}

void _sig_die(int signo)
{
46
    INFO1("Caught signal %d, shutting down...", signo);
Jack Moffitt's avatar
Jack Moffitt committed
47

48 49
    /* inform the server to start shutting down */
    global.running = ICE_HALTING;
Jack Moffitt's avatar
Jack Moffitt committed
50 51 52
}

#endif