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 {
32 void sigalrm_handler(int sig)
37 void sigterm_handler(int sig)
39 server_die("received signal SIGTERM");
42 static void sighup_handler(int sig)
48 static void sigint_handler(int sig)
50 GlobalRestartFlag = 1;
53 void setup_signals(void)
57 act.sa_handler = SIG_IGN;
59 sigemptyset(&act.sa_mask);
60 sigaddset(&act.sa_mask, SIGPIPE);
61 sigaddset(&act.sa_mask, SIGALRM);
63 sigaddset(&act.sa_mask, SIGWINCH);
64 sigaction(SIGWINCH, &act, 0);
66 sigaction(SIGPIPE, &act, 0);
68 act.sa_handler = sigalrm_handler;
69 sigaction(SIGALRM, &act, 0);
71 sigemptyset(&act.sa_mask);
73 act.sa_handler = sighup_handler;
74 sigaction(SIGHUP, &act, 0);
76 act.sa_handler = sigint_handler;
77 sigaction(SIGINT, &act, 0);
79 act.sa_handler = sigterm_handler;
80 sigaction(SIGTERM, &act, 0);
82 #ifdef HAVE_RESTARTABLE_SYSCALLS
84 * At least on Apollo sr10.1 it seems continuing system calls
85 * after signal is the default. The following 'siginterrupt'
86 * should change that default to interrupting calls.
88 siginterrupt(SIGALRM, 1);