ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/src/ircd_signal.c
Revision: 78
Committed: Tue Oct 4 21:16:00 2005 UTC (20 years, 9 months ago) by adx
Content type: text/x-csrc
File size: 2726 byte(s)
Log Message:
- further win32 fixes, use ircd_signal.c interface (signals are wrapped
  around WM_USER's wParam)
- note that the callback for WM_SIGNAL (ie WM_USER) defined in libio is
  independent from the ircd, ie variable dispatch_wm_signal is set in
  ircd_signal.c.
- now it compiles, to do: turn libio into a DLL to allow symbol references
  in m_*.dll protocol modules.

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

Properties

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