ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/ircd_signal.c
Revision: 2832
Committed: Thu Jan 16 16:53:34 2014 UTC (11 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 3063 byte(s)
Log Message:
- ircd_signal.c: minor fixes to sigchld_handler()

File Contents

# Content
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 "memory.h"
31 #include "s_bsd.h"
32
33 /*
34 * sigterm_handler - exit the server
35 */
36 static void
37 sigterm_handler(int sig)
38 {
39 server_die("received signal SIGTERM", 0);
40 }
41
42 /*
43 * sighup_handler - reread the server configuration
44 */
45 static void
46 sighup_handler(int sig)
47 {
48 dorehash = 1;
49 }
50
51 /*
52 * sigusr1_handler - reread the motd file
53 */
54 static void
55 sigusr1_handler(int sig)
56 {
57 doremotd = 1;
58 }
59
60 /*
61 *
62 * inputs - nothing
63 * output - nothing
64 * side effects - Reaps zombies periodically
65 * -AndroSyn
66 */
67 static void
68 sigchld_handler(int sig)
69 {
70 int status, errno_save = errno;
71
72 while (waitpid(-1, &status, WNOHANG) > 0)
73 ;
74 errno = errno_save;
75 }
76
77 /*
78 * sigint_handler - restart the server
79 */
80 static void
81 sigint_handler(int sig)
82 {
83 server_die("SIGINT received", !server_state.foreground);
84 }
85
86 /*
87 * setup_signals - initialize signal handlers for server
88 */
89 void
90 setup_signals(void)
91 {
92 struct sigaction act;
93
94 act.sa_flags = 0;
95 act.sa_handler = SIG_IGN;
96
97 sigemptyset(&act.sa_mask);
98 sigaddset(&act.sa_mask, SIGPIPE);
99 sigaddset(&act.sa_mask, SIGALRM);
100 sigaction(SIGALRM, &act, 0);
101 #ifdef SIGTRAP
102 sigaddset(&act.sa_mask, SIGTRAP);
103 #endif
104 #ifdef SIGXFSZ
105 sigaddset(&act.sa_mask, SIGXFSZ);
106 sigaction(SIGXFSZ, &act, 0);
107 #endif
108
109 #ifdef SIGWINCH
110 sigaddset(&act.sa_mask, SIGWINCH);
111 sigaction(SIGWINCH, &act, 0);
112 #endif
113 sigaction(SIGPIPE, &act, 0);
114 #ifdef SIGTRAP
115 sigaction(SIGTRAP, &act, 0);
116 #endif
117
118 act.sa_handler = sighup_handler;
119 sigemptyset(&act.sa_mask);
120 sigaddset(&act.sa_mask, SIGHUP);
121 sigaction(SIGHUP, &act, 0);
122
123 act.sa_handler = sigint_handler;
124 sigaddset(&act.sa_mask, SIGINT);
125 sigaction(SIGINT, &act, 0);
126
127 act.sa_handler = sigterm_handler;
128 sigaddset(&act.sa_mask, SIGTERM);
129 sigaction(SIGTERM, &act, 0);
130
131 act.sa_handler = sigusr1_handler;
132 sigaddset(&act.sa_mask, SIGUSR1);
133 sigaction(SIGUSR1, &act, 0);
134
135 act.sa_handler = sigchld_handler;
136 sigaddset(&act.sa_mask, SIGCHLD);
137 sigaction(SIGCHLD, &act, 0);
138 }

Properties

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