ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/ircd_signal.c
Revision: 1156
Committed: Tue Aug 9 20:29:20 2011 UTC (14 years ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/src/ircd_signal.c
File size: 3022 byte(s)
Log Message:
- create ircd-hybrid-8 "branch"

File Contents

# User Rev Content
1 adx 30 /*
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 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26 michael 1011 #include "list.h"
27 adx 30 #include "ircd_signal.h"
28     #include "ircd.h" /* dorehash */
29 michael 594 #include "restart.h" /* server_die */
30 adx 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 michael 1011 server_die("received signal SIGTERM", 0);
41 adx 30 }
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 michael 594 server_die("SIGINT received", !server_state.foreground);
82 adx 30 }
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 michael 594
95 adx 30 sigemptyset(&act.sa_mask);
96     sigaddset(&act.sa_mask, SIGPIPE);
97     sigaddset(&act.sa_mask, SIGALRM);
98 michael 598 sigaction(SIGALRM, &act, 0);
99 adx 30 #ifdef SIGTRAP
100     sigaddset(&act.sa_mask, SIGTRAP);
101     #endif
102 michael 594 #ifdef SIGXFSZ
103     sigaddset(&act.sa_mask, SIGXFSZ);
104     sigaction(SIGXFSZ, &act, 0);
105     #endif
106 adx 30
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