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.
|
|
|
|
*
|
2015-01-10 13:53:44 -05:00
|
|
|
* Copyright 2000-2004, Jack Moffitt <jack@xiph.org,
|
2004-01-28 20:02:12 -05:00
|
|
|
* Michael Smith <msmith@xiph.org>,
|
|
|
|
* oddsock <oddsock@xiph.org>,
|
|
|
|
* Karl Heyes <karl@xiph.org>
|
|
|
|
* and others (see AUTHORS for details).
|
2018-11-26 02:42:05 -05:00
|
|
|
* Copyright 2011-2015, Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
|
2004-01-28 20:02:12 -05:00
|
|
|
*/
|
|
|
|
|
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>
|
|
|
|
|
2014-12-02 16:50:57 -05:00
|
|
|
#include "common/thread/thread.h"
|
|
|
|
#include "common/avl/avl.h"
|
|
|
|
#include "common/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"
|
|
|
|
|
|
|
|
#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)
|
|
|
|
{
|
2014-10-31 04:46:58 -04:00
|
|
|
ICECAST_LOG_INFO("Caught signal %d, scheduling config re-read...", signo);
|
2012-10-11 18:49:57 -04:00
|
|
|
|
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)
|
|
|
|
{
|
2014-10-31 04:46:58 -04:00
|
|
|
ICECAST_LOG_INFO("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 */
|
2014-10-31 05:00:45 -04:00
|
|
|
global.running = ICECAST_HALTING;
|
2001-09-09 22:21:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|