1 /* Icecast
2  *
3  * This program is distributed under the GNU General Public License, version 2.
4  * A copy of this license is included with this source.
5  *
6  * Copyright 2000-2004, Jack Moffitt <jack@xiph.org,
7  *                      Michael Smith <msmith@xiph.org>,
8  *                      oddsock <oddsock@xiph.org>,
9  *                      Karl Heyes <karl@xiph.org>
10  *                      and others (see AUTHORS for details).
11  */
12 
13 #ifdef HAVE_CONFIG_H
14 #include <config.h>
15 #endif
16 
17 #include <signal.h>
18 
19 #include "thread/thread.h"
20 #include "avl/avl.h"
21 #include "httpp/httpp.h"
22 
23 #include "connection.h"
24 #include "refbuf.h"
25 #include "client.h"
26 #include "logging.h"
27 #include "event.h"
28 #include "global.h"
29 
30 #define CATMODULE "sighandler"
31 
32 #ifndef _WIN32
33 void _sig_hup(int signo);
34 void _sig_die(int signo);
35 void _sig_ignore(int signo);
36 #endif
37 
sighandler_initialize(void)38 void sighandler_initialize(void)
39 {
40 #ifndef _WIN32
41     signal(SIGHUP, _sig_hup);
42     signal(SIGINT, _sig_die);
43     signal(SIGTERM, _sig_die);
44     signal(SIGPIPE, SIG_IGN);
45     signal(SIGCHLD, _sig_ignore);
46 #endif
47 }
48 
49 #ifndef _WIN32
_sig_ignore(int signo)50 void _sig_ignore(int signo)
51 {
52     signal(signo, _sig_ignore);
53 }
54 
_sig_hup(int signo)55 void _sig_hup(int signo)
56 {
57     global . schedule_config_reread = 1;
58     /* some OSes require us to reattach the signal handler */
59     signal(SIGHUP, _sig_hup);
60 }
61 
_sig_die(int signo)62 void _sig_die(int signo)
63 {
64     /* inform the server to start shutting down */
65     global.running = ICE_HALTING;
66 }
67 
68 #endif
69