ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/src/ircd_signal.c
Revision: 69
Committed: Tue Oct 4 16:09:51 2005 UTC (20 years, 10 months ago) by adx
Content type: text/x-csrc
File size: 2899 byte(s)
Log Message:
- splitted ircd/libio, all headers connected with libio sources have been
  moved for internal use only. To use libio interface, include "libio.h"
  (which is already done in "stdinc.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     #include "common.h"
27     #include "ircd_signal.h"
28     #include "ircd.h" /* dorehash */
29     #include "restart.h" /* server_reboot */
30    
31     /*
32     * sigterm_handler - exit the server
33     */
34     static void
35     sigterm_handler(int sig)
36     {
37     server_die("received signal SIGTERM", NO);
38     }
39    
40     /*
41     * sighup_handler - reread the server configuration
42     */
43     static void
44     sighup_handler(int sig)
45     {
46     dorehash = 1;
47     }
48    
49     /*
50     * sigusr1_handler - reread the motd file
51     */
52     static void
53     sigusr1_handler(int sig)
54     {
55     doremotd = 1;
56     }
57    
58     /*
59     *
60     * inputs - nothing
61     * output - nothing
62     * side effects - Reaps zombies periodically
63     * -AndroSyn
64     */
65     static void
66     sigchld_handler(int sig)
67     {
68     int status;
69     waitpid(-1, &status, WNOHANG);
70     }
71    
72     /*
73     * sigint_handler - restart the server
74     */
75     static void
76     sigint_handler(int sig)
77     {
78     if (server_state.foreground)
79     server_die("SIGINT received", NO);
80     else
81     restart("SIGINT received");
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     sigemptyset(&act.sa_mask);
95     sigaddset(&act.sa_mask, SIGPIPE);
96     sigaddset(&act.sa_mask, SIGALRM);
97     #ifdef SIGTRAP
98     sigaddset(&act.sa_mask, SIGTRAP);
99     #endif
100    
101     #ifdef SIGWINCH
102     sigaddset(&act.sa_mask, SIGWINCH);
103     sigaction(SIGWINCH, &act, 0);
104     #endif
105     sigaction(SIGPIPE, &act, 0);
106     #ifdef SIGTRAP
107     sigaction(SIGTRAP, &act, 0);
108     #endif
109    
110     act.sa_handler = sighup_handler;
111     sigemptyset(&act.sa_mask);
112     sigaddset(&act.sa_mask, SIGHUP);
113     sigaction(SIGHUP, &act, 0);
114    
115     act.sa_handler = sigint_handler;
116     sigaddset(&act.sa_mask, SIGINT);
117     sigaction(SIGINT, &act, 0);
118    
119     act.sa_handler = sigterm_handler;
120     sigaddset(&act.sa_mask, SIGTERM);
121     sigaction(SIGTERM, &act, 0);
122    
123     act.sa_handler = sigusr1_handler;
124     sigaddset(&act.sa_mask, SIGUSR1);
125     sigaction(SIGUSR1, &act, 0);
126    
127     act.sa_handler = sigchld_handler;
128     sigaddset(&act.sa_mask, SIGCHLD);
129     sigaction(SIGCHLD, &act, 0);
130     }

Properties

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