2 * IRC - Internet Relay Chat, ircd/ircd_signal.c
3 * Copyright (C) 1990 Jarkko Oikarinen and
4 * University of Oulu, Computing Center
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 1, or (at your option)
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "ircd_signal.h"
27 static struct tag_SignalCounter {
33 void s_monitor(int sig)
43 void sigalrm_handler(int sig)
48 void sigterm_handler(int sig)
50 server_die("received signal SIGTERM");
53 static void sighup_handler(int sig)
59 static void sigint_handler(int sig)
61 GlobalRestartFlag = 1;
64 void setup_signals(void)
68 act.sa_handler = SIG_IGN;
70 sigemptyset(&act.sa_mask);
71 sigaddset(&act.sa_mask, SIGPIPE);
72 sigaddset(&act.sa_mask, SIGALRM);
74 sigaddset(&act.sa_mask, SIGWINCH);
75 sigaction(SIGWINCH, &act, 0);
77 sigaction(SIGPIPE, &act, 0);
79 act.sa_handler = sigalrm_handler;
80 sigaction(SIGALRM, &act, 0);
82 sigemptyset(&act.sa_mask);
84 act.sa_handler = sighup_handler;
85 sigaction(SIGHUP, &act, 0);
87 act.sa_handler = sigint_handler;
88 sigaction(SIGINT, &act, 0);
90 act.sa_handler = sigterm_handler;
91 sigaction(SIGTERM, &act, 0);
93 #ifdef HAVE_RESTARTABLE_SYSCALLS
95 * At least on Apollo sr10.1 it seems continuing system calls
96 * after signal is the default. The following 'siginterrupt'
97 * should change that default to interrupting calls.
99 siginterrupt(SIGALRM, 1);