ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/branches/ircd-hybrid-newconf/src/ircd_signal.c
Revision: 1027
Committed: Sun Nov 8 13:01:13 2009 UTC (16 years, 9 months ago) by michael
Content type: text/x-csrc
File size: 2742 byte(s)
Log Message:
- Move old 7.3 sources to branches/ircd-hybrid-newconf

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 "ircd_signal.h"
27 #include "ircd.h" /* dorehash */
28 #include "restart.h" /* server_die */
29
30 /*
31 * signal_handler - general handler for ircd signals
32 */
33 static void
34 signal_handler(int sig)
35 {
36 switch (sig)
37 {
38 case SIG_DIE:
39 server_die("received signal SIGTERM", NO);
40 break;
41 case SIG_RESTART:
42 server_die("received signal SIGINT", !ServerState.foreground);
43 break;
44 case SIG_REHASH:
45 dorehash = 1;
46 break;
47 case SIG_REMOTD:
48 doremotd = 1;
49 }
50 }
51
52 #ifndef _WIN32
53 /*
54 *
55 * inputs - nothing
56 * output - nothing
57 * side effects - Reaps zombies periodically
58 * -AndroSyn
59 */
60 static void
61 sigchld_handler(int sig)
62 {
63 int status;
64 waitpid(-1, &status, WNOHANG);
65 }
66 #endif
67
68 /*
69 * setup_signals - initialize signal handlers for server
70 */
71 void
72 setup_signals(void)
73 {
74 #ifdef _WIN32
75 dispatch_wm_signal = signal_handler;
76 #else
77 struct sigaction act;
78
79 act.sa_flags = 0;
80 act.sa_handler = SIG_IGN;
81
82 sigemptyset(&act.sa_mask);
83
84 sigaddset(&act.sa_mask, SIGPIPE);
85 sigaction(SIGPIPE, &act, 0);
86
87 sigaddset(&act.sa_mask, SIGALRM);
88 sigaction(SIGALRM, &act, 0);
89
90 #ifdef SIGWINCH
91 sigaddset(&act.sa_mask, SIGWINCH);
92 sigaction(SIGWINCH, &act, 0);
93 #endif
94
95 #ifdef SIGXFSZ
96 sigaddset(&act.sa_mask, SIGXFSZ);
97 sigaction(SIGXFSZ, &act, 0);
98 #endif
99
100 act.sa_handler = signal_handler;
101 sigemptyset(&act.sa_mask);
102
103 sigaddset(&act.sa_mask, SIG_REHASH);
104 sigaction(SIG_REHASH, &act, 0);
105
106 sigaddset(&act.sa_mask, SIG_RESTART);
107 sigaction(SIG_RESTART, &act, 0);
108
109 sigaddset(&act.sa_mask, SIG_DIE);
110 sigaction(SIG_DIE, &act, 0);
111
112 sigaddset(&act.sa_mask, SIG_REMOTD);
113 sigaction(SIG_REMOTD, &act, 0);
114
115 act.sa_handler = sigchld_handler;
116 sigaddset(&act.sa_mask, SIGCHLD);
117 sigaction(SIGCHLD, &act, 0);
118 #endif
119 }

Properties

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