ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/ircd_signal.c
(Generate patch)

Comparing:
ircd-hybrid-7.2/src/ircd_signal.c (file contents), Revision 594 by michael, Fri May 12 20:05:57 2006 UTC vs.
ircd-hybrid/trunk/src/ircd_signal.c (file contents), Revision 7006 by michael, Fri Jan 1 00:07:54 2016 UTC

# Line 1 | Line 1
1   /*
2 < *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  ircd_signal.c: responsible for ircd's signal handling
2 > *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (C) 2002 by the past and present ircd coders, and others.
4 > *  Copyright (c) 1997-2016 ircd-hybrid development team
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 16 | Line 15
15   *
16   *  You should have received a copy of the GNU General Public License
17   *  along with this program; if not, write to the Free Software
18 < *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
18 > *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19   *  USA
20 < *
21 < *  $Id$
20 > */
21 >
22 > /*! \file ircd_signal.c
23 > * \brief responsible for ircd's signal handling.
24 > * \version $Id$
25   */
26  
27   #include "stdinc.h"
26 #include "common.h"
28   #include "ircd_signal.h"
29 < #include "ircd.h"         /* dorehash */
30 < #include "restart.h"      /* server_die */
31 < #include "s_log.h"
31 < #include "memory.h"
32 < #include "s_bsd.h"
29 > #include "ircd.h"
30 > #include "restart.h"
31 >
32  
33   /*
34   * sigterm_handler - exit the server
35   */
36 < static void
37 < sigterm_handler(int sig)  
36 > static void
37 > sigterm_handler(int sig)
38   {
39 <  server_die("received signal SIGTERM", NO);
39 >  server_die("received signal SIGTERM", SERVER_SHUTDOWN);
40   }
41  
42 < /*
42 > /*
43   * sighup_handler - reread the server configuration
44   */
45 < static void
45 > static void
46   sighup_handler(int sig)
47   {
48    dorehash = 1;
# Line 59 | Line 58 | sigusr1_handler(int sig)
58   }
59  
60   /*
61 < *
61 > *
62   * inputs       - nothing
63   * output       - nothing
64   * side effects - Reaps zombies periodically
# Line 68 | Line 67 | sigusr1_handler(int sig)
67   static void
68   sigchld_handler(int sig)
69   {
70 <  int status;
71 <  waitpid(-1, &status, WNOHANG);
70 >  int status, errno_save = errno;
71 >
72 >  while (waitpid(-1, &status, WNOHANG) > 0)
73 >    ;
74 >  errno = errno_save;
75   }
76  
77   /*
78   * sigint_handler - restart the server
79   */
80 < static void
80 > static void
81   sigint_handler(int sig)
82   {
83 <  server_die("SIGINT received", !server_state.foreground);
83 >  server_die("received signal SIGINT", server_state.foreground ? SERVER_SHUTDOWN : SERVER_RESTART);
84   }
85  
86   /*
87   * setup_signals - initialize signal handlers for server
88   */
89 < void
89 > void
90   setup_signals(void)
91   {
92    struct sigaction act;
# Line 93 | Line 95 | setup_signals(void)
95    act.sa_handler = SIG_IGN;
96  
97    sigemptyset(&act.sa_mask);
98 <  sigaddset(&act.sa_mask, SIGPIPE);
99 <  sigaddset(&act.sa_mask, SIGALRM);
98 > #ifdef SIGXFSZ
99 >  sigaddset(&act.sa_mask, SIGXFSZ);
100 > #endif
101 > #ifdef SIGWINCH
102 >  sigaddset(&act.sa_mask, SIGWINCH);
103 > #endif
104   #ifdef SIGTRAP
105    sigaddset(&act.sa_mask, SIGTRAP);
106   #endif
107 +  sigaddset(&act.sa_mask, SIGPIPE);
108 +  sigaddset(&act.sa_mask, SIGALRM);
109 +  sigaddset(&act.sa_mask, SIGHUP);
110 +  sigaddset(&act.sa_mask, SIGINT);
111 +  sigaddset(&act.sa_mask, SIGTERM);
112 +  sigaddset(&act.sa_mask, SIGUSR1);
113 +  sigaddset(&act.sa_mask, SIGCHLD);
114 +
115   #ifdef SIGXFSZ
102  sigaddset(&act.sa_mask, SIGXFSZ);
116    sigaction(SIGXFSZ, &act, 0);
117   #endif
105
118   #ifdef SIGWINCH
107  sigaddset(&act.sa_mask, SIGWINCH);
119    sigaction(SIGWINCH, &act, 0);
120   #endif
110  sigaction(SIGPIPE, &act, 0);
121   #ifdef SIGTRAP
122    sigaction(SIGTRAP, &act, 0);
123   #endif
124 +  sigaction(SIGPIPE, &act, 0);
125 +  sigaction(SIGALRM, &act, 0);
126  
127    act.sa_handler = sighup_handler;
116  sigemptyset(&act.sa_mask);
117  sigaddset(&act.sa_mask, SIGHUP);
128    sigaction(SIGHUP, &act, 0);
129  
130    act.sa_handler = sigint_handler;
121  sigaddset(&act.sa_mask, SIGINT);
131    sigaction(SIGINT, &act, 0);
132  
133    act.sa_handler = sigterm_handler;
125  sigaddset(&act.sa_mask, SIGTERM);
134    sigaction(SIGTERM, &act, 0);
135  
136    act.sa_handler = sigusr1_handler;
129  sigaddset(&act.sa_mask, SIGUSR1);
137    sigaction(SIGUSR1, &act, 0);
138  
139    act.sa_handler = sigchld_handler;
133  sigaddset(&act.sa_mask, SIGCHLD);
140    sigaction(SIGCHLD, &act, 0);
141 +
142 +  sigprocmask(SIG_UNBLOCK, &act.sa_mask, NULL);
143   }

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)