]>
jfr.im git - irc/rqf/shadowircd.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.
23 #include "ircd_signal.h"
24 #include "ircd.h" /* dorehash */
25 #include "restart.h" /* server_reboot */
32 * dummy_handler - don't know if this is really needed but if alarm is still
33 * being used we probably will
36 dummy_handler(int sig
)
43 sigchld_handler(int sig
)
48 while (waitpid(-1, &status
, WNOHANG
) > 0)
54 * sigterm_handler - exit the server
57 sigterm_handler(int sig
)
59 ircd_shutdown("Received SIGTERM");
63 * sighup_handler - reread the server configuration
66 sighup_handler(int sig
)
72 * sigusr1_handler - reread the motd file
75 sigusr1_handler(int sig
)
81 sigusr2_handler(int sig
)
87 * sigint_handler - restart the server
90 sigint_handler(int sig
)
92 static int restarting
= 0;
94 if(server_state_foreground
)
96 ilog(L_MAIN
, "Server exiting on SIGINT");
101 ilog(L_MAIN
, "Server Restarting on SIGINT");
111 * setup_signals - initialize signal handlers for server
116 struct sigaction act
;
119 act
.sa_handler
= SIG_IGN
;
120 sigemptyset(&act
.sa_mask
);
121 sigaddset(&act
.sa_mask
, SIGPIPE
);
122 sigaddset(&act
.sa_mask
, SIGALRM
);
124 sigaddset(&act
.sa_mask
, SIGTRAP
);
128 sigaddset(&act
.sa_mask
, SIGWINCH
);
129 sigaction(SIGWINCH
, &act
, 0);
131 sigaction(SIGPIPE
, &act
, 0);
133 sigaction(SIGTRAP
, &act
, 0);
136 act
.sa_handler
= dummy_handler
;
137 sigaction(SIGALRM
, &act
, 0);
139 act
.sa_handler
= sighup_handler
;
140 sigemptyset(&act
.sa_mask
);
141 sigaddset(&act
.sa_mask
, SIGHUP
);
142 sigaction(SIGHUP
, &act
, 0);
144 act
.sa_handler
= sigint_handler
;
145 sigaddset(&act
.sa_mask
, SIGINT
);
146 sigaction(SIGINT
, &act
, 0);
148 act
.sa_handler
= sigterm_handler
;
149 sigaddset(&act
.sa_mask
, SIGTERM
);
150 sigaction(SIGTERM
, &act
, 0);
152 act
.sa_handler
= sigusr1_handler
;
153 sigaddset(&act
.sa_mask
, SIGUSR1
);
154 sigaction(SIGUSR1
, &act
, 0);
156 act
.sa_handler
= sigusr2_handler
;
157 sigaddset(&act
.sa_mask
, SIGUSR2
);
158 sigaction(SIGUSR2
, &act
, 0);
160 act
.sa_handler
= sigchld_handler
;
161 sigaddset(&act
.sa_mask
, SIGCHLD
);
162 sigaction(SIGCHLD
, &act
, 0);