]>
jfr.im git - solanum.git/blob - src/ircd_signal.c
1 /************************************************************************
2 * IRC - Internet Relay Chat, src/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.
20 * $Id: ircd_signal.c 6 2005-09-10 01:02:21Z nenolod $
24 #include "ircd_signal.h"
25 #include "ircd.h" /* dorehash */
26 #include "restart.h" /* server_reboot */
33 * dummy_handler - don't know if this is really needed but if alarm is still
34 * being used we probably will
37 dummy_handler(int sig
)
44 sigchld_handler(int sig
)
49 while (waitpid(-1, &status
, WNOHANG
) > 0)
55 * sigterm_handler - exit the server
58 sigterm_handler(int sig
)
60 ircd_shutdown("Received SIGTERM");
64 * sighup_handler - reread the server configuration
67 sighup_handler(int sig
)
73 * sigusr1_handler - reread the motd file
76 sigusr1_handler(int sig
)
82 sigusr2_handler(int sig
)
88 * sigint_handler - restart the server
91 sigint_handler(int sig
)
93 static int restarting
= 0;
95 if(server_state_foreground
)
97 ilog(L_MAIN
, "Server exiting on SIGINT");
102 ilog(L_MAIN
, "Server Restarting on SIGINT");
112 * setup_signals - initialize signal handlers for server
117 struct sigaction act
;
120 act
.sa_handler
= SIG_IGN
;
121 sigemptyset(&act
.sa_mask
);
122 sigaddset(&act
.sa_mask
, SIGPIPE
);
123 sigaddset(&act
.sa_mask
, SIGALRM
);
125 sigaddset(&act
.sa_mask
, SIGTRAP
);
129 sigaddset(&act
.sa_mask
, SIGWINCH
);
130 sigaction(SIGWINCH
, &act
, 0);
132 sigaction(SIGPIPE
, &act
, 0);
134 sigaction(SIGTRAP
, &act
, 0);
137 act
.sa_handler
= dummy_handler
;
138 sigaction(SIGALRM
, &act
, 0);
140 act
.sa_handler
= sighup_handler
;
141 sigemptyset(&act
.sa_mask
);
142 sigaddset(&act
.sa_mask
, SIGHUP
);
143 sigaction(SIGHUP
, &act
, 0);
145 act
.sa_handler
= sigint_handler
;
146 sigaddset(&act
.sa_mask
, SIGINT
);
147 sigaction(SIGINT
, &act
, 0);
149 act
.sa_handler
= sigterm_handler
;
150 sigaddset(&act
.sa_mask
, SIGTERM
);
151 sigaction(SIGTERM
, &act
, 0);
153 act
.sa_handler
= sigusr1_handler
;
154 sigaddset(&act
.sa_mask
, SIGUSR1
);
155 sigaction(SIGUSR1
, &act
, 0);
157 act
.sa_handler
= sigusr2_handler
;
158 sigaddset(&act
.sa_mask
, SIGUSR2
);
159 sigaction(SIGUSR2
, &act
, 0);
161 act
.sa_handler
= sigchld_handler
;
162 sigaddset(&act
.sa_mask
, SIGCHLD
);
163 sigaction(SIGCHLD
, &act
, 0);