ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/branches/ircd-hybrid-newconf/src/ircd_signal.c
Revision: 600
Committed: Sat May 13 09:30:18 2006 UTC (20 years, 2 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid/src/ircd_signal.c
File size: 2853 byte(s)
Log Message:
- Don't code while having a breakfast!  Now here's the other missing
  half of the previous commit which fixes SIGALRM handling.

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

Properties

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