ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/ircd_signal.c
Revision: 1309
Committed: Sun Mar 25 11:24:18 2012 UTC (13 years, 5 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/src/ircd_signal.c
File size: 3003 byte(s)
Log Message:
- renaming files:

  ircd_parser.y -> conf_parser.y
  ircd_lexer.l  -> conf_lexer.l
  s_conf.c      -> conf.c
  s_conf.h      -> conf.h
  s_log.c       -> log.c
  s_log.h       -> log.h

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 "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 michael 1011 server_die("received signal SIGTERM", 0);
40 adx 30 }
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;
71     waitpid(-1, &status, WNOHANG);
72     }
73    
74     /*
75     * sigint_handler - restart the server
76     */
77     static void
78     sigint_handler(int sig)
79     {
80 michael 594 server_die("SIGINT received", !server_state.foreground);
81 adx 30 }
82    
83     /*
84     * setup_signals - initialize signal handlers for server
85     */
86     void
87     setup_signals(void)
88     {
89     struct sigaction act;
90    
91     act.sa_flags = 0;
92     act.sa_handler = SIG_IGN;
93 michael 594
94 adx 30 sigemptyset(&act.sa_mask);
95     sigaddset(&act.sa_mask, SIGPIPE);
96     sigaddset(&act.sa_mask, SIGALRM);
97 michael 598 sigaction(SIGALRM, &act, 0);
98 adx 30 #ifdef SIGTRAP
99     sigaddset(&act.sa_mask, SIGTRAP);
100     #endif
101 michael 594 #ifdef SIGXFSZ
102     sigaddset(&act.sa_mask, SIGXFSZ);
103     sigaction(SIGXFSZ, &act, 0);
104     #endif
105 adx 30
106     #ifdef SIGWINCH
107     sigaddset(&act.sa_mask, SIGWINCH);
108     sigaction(SIGWINCH, &act, 0);
109     #endif
110     sigaction(SIGPIPE, &act, 0);
111     #ifdef SIGTRAP
112     sigaction(SIGTRAP, &act, 0);
113     #endif
114    
115     act.sa_handler = sighup_handler;
116     sigemptyset(&act.sa_mask);
117     sigaddset(&act.sa_mask, SIGHUP);
118     sigaction(SIGHUP, &act, 0);
119    
120     act.sa_handler = sigint_handler;
121     sigaddset(&act.sa_mask, SIGINT);
122     sigaction(SIGINT, &act, 0);
123    
124     act.sa_handler = sigterm_handler;
125     sigaddset(&act.sa_mask, SIGTERM);
126     sigaction(SIGTERM, &act, 0);
127    
128     act.sa_handler = sigusr1_handler;
129     sigaddset(&act.sa_mask, SIGUSR1);
130     sigaction(SIGUSR1, &act, 0);
131    
132     act.sa_handler = sigchld_handler;
133     sigaddset(&act.sa_mask, SIGCHLD);
134     sigaction(SIGCHLD, &act, 0);
135     }

Properties

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