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.
24 #include "ircd_signal.h"
29 static struct tag_SignalCounter {
34 void sigalrm_handler(int sig)
39 void sigterm_handler(int sig)
41 server_die("received signal SIGTERM");
44 static void sighup_handler(int sig)
50 static void sigint_handler(int sig)
52 GlobalRestartFlag = 1;
55 void setup_signals(void)
59 act.sa_handler = SIG_IGN;
61 sigemptyset(&act.sa_mask);
62 sigaddset(&act.sa_mask, SIGPIPE);
63 sigaddset(&act.sa_mask, SIGALRM);
65 sigaddset(&act.sa_mask, SIGWINCH);
66 sigaction(SIGWINCH, &act, 0);
68 sigaction(SIGPIPE, &act, 0);
70 act.sa_handler = sigalrm_handler;
71 sigaction(SIGALRM, &act, 0);
73 sigemptyset(&act.sa_mask);
75 act.sa_handler = sighup_handler;
76 sigaction(SIGHUP, &act, 0);
78 act.sa_handler = sigint_handler;
79 sigaction(SIGINT, &act, 0);
81 act.sa_handler = sigterm_handler;
82 sigaction(SIGTERM, &act, 0);
84 #ifdef HAVE_RESTARTABLE_SYSCALLS
86 * At least on Apollo sr10.1 it seems continuing system calls
87 * after signal is the default. The following 'siginterrupt'
88 * should change that default to interrupting calls.
90 siginterrupt(SIGALRM, 1);