2004-01-28 20:02:12 -05:00
|
|
|
/* Icecast
|
|
|
|
*
|
|
|
|
* This program is distributed under the GNU General Public License, version 2.
|
|
|
|
* A copy of this license is included with this source.
|
|
|
|
*
|
|
|
|
* Copyright 2000-2004, Jack Moffitt <jack@xiph.org,
|
|
|
|
* Michael Smith <msmith@xiph.org>,
|
|
|
|
* oddsock <oddsock@xiph.org>,
|
|
|
|
* Karl Heyes <karl@xiph.org>
|
|
|
|
* and others (see AUTHORS for details).
|
|
|
|
*/
|
|
|
|
|
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);
|
2005-06-10 14:01:53 -04:00
|
|
|
void _sig_ignore(int signo);
|
2001-09-09 22:21:46 -04:00
|
|
|
#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);
|
2005-06-10 14:01:53 -04:00
|
|
|
signal(SIGCHLD, _sig_ignore);
|
2001-09-09 22:21:46 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
2005-06-10 14:01:53 -04:00
|
|
|
void _sig_ignore(int signo)
|
|
|
|
{
|
|
|
|
signal(signo, _sig_ignore);
|
|
|
|
}
|
2001-09-09 22:21:46 -04:00
|
|
|
|
|
|
|
void _sig_hup(int signo)
|
|
|
|
{
|
2012-07-17 10:03:37 -04:00
|
|
|
global_lock();
|
2003-07-25 10:29:33 -04:00
|
|
|
global . schedule_config_reread = 1;
|
2012-07-17 10:03:37 -04:00
|
|
|
global_unlock();
|
|
|
|
|
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
|