git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1225
c9e4aea6-c8fd-4c43-8297-
357d70d61c8c
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/** @file
+ * @brief Signal handlers for ircu.
+ * @version $Id$
#include <assert.h>
#include <signal.h>
#include <assert.h>
#include <signal.h>
+/** Counts various types of signals that we receive. */
static struct tag_SignalCounter {
static struct tag_SignalCounter {
- unsigned int alrm;
- unsigned int hup;
+ unsigned int alrm; /**< Received SIGALRM count. */
+ unsigned int hup; /**< Received SIGHUP count. */
+/** Event generator for SIGHUP. */
static struct Signal sig_hup;
static struct Signal sig_hup;
+/** Event generator for SIGINT. */
static struct Signal sig_int;
static struct Signal sig_int;
+/** Event generator for SIGTERM. */
static struct Signal sig_term;
static struct Signal sig_term;
+/** Signal handler for SIGALRM.
+ * @param[in] sig Signal number (ignored).
+ */
static void sigalrm_handler(int sig)
{
++SignalCounter.alrm;
}
static void sigalrm_handler(int sig)
{
++SignalCounter.alrm;
}
+/** Signal callback for SIGTERM.
+ * @param[in] ev Signal event descriptor.
+ */
static void sigterm_callback(struct Event* ev)
{
assert(0 != ev_signal(ev));
static void sigterm_callback(struct Event* ev)
{
assert(0 != ev_signal(ev));
server_die("received signal SIGTERM");
}
server_die("received signal SIGTERM");
}
+/** Signal callback for SIGHUP.
+ * @param[in] ev Signal event descriptor.
+ */
static void sighup_callback(struct Event* ev)
{
assert(0 != ev_signal(ev));
static void sighup_callback(struct Event* ev)
{
assert(0 != ev_signal(ev));
+/** Signal callback for SIGINT.
+ * @param[in] ev Signal event descriptor.
+ */
static void sigint_callback(struct Event* ev)
{
assert(0 != ev_signal(ev));
static void sigint_callback(struct Event* ev)
{
assert(0 != ev_signal(ev));
server_restart("caught signal: SIGINT");
}
server_restart("caught signal: SIGINT");
}
+/** Register all necessary signal handlers. */
void setup_signals(void)
{
struct sigaction act;
void setup_signals(void)
{
struct sigaction act;