/[svn]/ircd-hybrid-7.2/src/ircd_signal.c
ViewVC logotype

Contents of /ircd-hybrid-7.2/src/ircd_signal.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1011 - (show annotations)
Fri Sep 18 10:14:09 2009 UTC (10 years, 2 months ago) by michael
File MIME type: text/x-chdr
File size: 3022 byte(s)
- move list manipulation routines from tools.c to list.c
- mem_frob() goes to memory.c
- sort out redundant/unneeded header includes

1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * ircd_signal.c: responsible for ircd's signal handling
4 *
5 * Copyright (C) 2002 by the past and present ircd coders, and others.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 *
22 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "list.h"
27 #include "ircd_signal.h"
28 #include "ircd.h" /* dorehash */
29 #include "restart.h" /* server_die */
30 #include "s_log.h"
31 #include "memory.h"
32 #include "s_bsd.h"
33
34 /*
35 * sigterm_handler - exit the server
36 */
37 static void
38 sigterm_handler(int sig)
39 {
40 server_die("received signal SIGTERM", 0);
41 }
42
43 /*
44 * sighup_handler - reread the server configuration
45 */
46 static void
47 sighup_handler(int sig)
48 {
49 dorehash = 1;
50 }
51
52 /*
53 * sigusr1_handler - reread the motd file
54 */
55 static void
56 sigusr1_handler(int sig)
57 {
58 doremotd = 1;
59 }
60
61 /*
62 *
63 * inputs - nothing
64 * output - nothing
65 * side effects - Reaps zombies periodically
66 * -AndroSyn
67 */
68 static void
69 sigchld_handler(int sig)
70 {
71 int status;
72 waitpid(-1, &status, WNOHANG);
73 }
74
75 /*
76 * sigint_handler - restart the server
77 */
78 static void
79 sigint_handler(int sig)
80 {
81 server_die("SIGINT received", !server_state.foreground);
82 }
83
84 /*
85 * setup_signals - initialize signal handlers for server
86 */
87 void
88 setup_signals(void)
89 {
90 struct sigaction act;
91
92 act.sa_flags = 0;
93 act.sa_handler = SIG_IGN;
94
95 sigemptyset(&act.sa_mask);
96 sigaddset(&act.sa_mask, SIGPIPE);
97 sigaddset(&act.sa_mask, SIGALRM);
98 sigaction(SIGALRM, &act, 0);
99 #ifdef SIGTRAP
100 sigaddset(&act.sa_mask, SIGTRAP);
101 #endif
102 #ifdef SIGXFSZ
103 sigaddset(&act.sa_mask, SIGXFSZ);
104 sigaction(SIGXFSZ, &act, 0);
105 #endif
106
107 #ifdef SIGWINCH
108 sigaddset(&act.sa_mask, SIGWINCH);
109 sigaction(SIGWINCH, &act, 0);
110 #endif
111 sigaction(SIGPIPE, &act, 0);
112 #ifdef SIGTRAP
113 sigaction(SIGTRAP, &act, 0);
114 #endif
115
116 act.sa_handler = sighup_handler;
117 sigemptyset(&act.sa_mask);
118 sigaddset(&act.sa_mask, SIGHUP);
119 sigaction(SIGHUP, &act, 0);
120
121 act.sa_handler = sigint_handler;
122 sigaddset(&act.sa_mask, SIGINT);
123 sigaction(SIGINT, &act, 0);
124
125 act.sa_handler = sigterm_handler;
126 sigaddset(&act.sa_mask, SIGTERM);
127 sigaction(SIGTERM, &act, 0);
128
129 act.sa_handler = sigusr1_handler;
130 sigaddset(&act.sa_mask, SIGUSR1);
131 sigaction(SIGUSR1, &act, 0);
132
133 act.sa_handler = sigchld_handler;
134 sigaddset(&act.sa_mask, SIGCHLD);
135 sigaction(SIGCHLD, &act, 0);
136 }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.26