00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "stdinc.h"
00026 #include "common.h"
00027 #include "ircd_signal.h"
00028 #include "ircd.h"
00029 #include "restart.h"
00030 #include "s_log.h"
00031 #include "memory.h"
00032 #include "s_bsd.h"
00033
00034
00035
00036
00037 static void
00038 sigterm_handler(int sig)
00039 {
00040 server_die("received signal SIGTERM", NO);
00041 }
00042
00043
00044
00045
00046 static void
00047 sighup_handler(int sig)
00048 {
00049 dorehash = 1;
00050 }
00051
00052
00053
00054
00055 static void
00056 sigusr1_handler(int sig)
00057 {
00058 doremotd = 1;
00059 }
00060
00061
00062
00063
00064
00065
00066
00067
00068 static void
00069 sigchld_handler(int sig)
00070 {
00071 int status;
00072 waitpid(-1, &status, WNOHANG);
00073 }
00074
00075
00076
00077
00078 static void
00079 sigint_handler(int sig)
00080 {
00081 server_die("SIGINT received", !server_state.foreground);
00082 }
00083
00084
00085
00086
00087 void
00088 setup_signals(void)
00089 {
00090 struct sigaction act;
00091
00092 act.sa_flags = 0;
00093 act.sa_handler = SIG_IGN;
00094
00095 sigemptyset(&act.sa_mask);
00096 sigaddset(&act.sa_mask, SIGPIPE);
00097 sigaddset(&act.sa_mask, SIGALRM);
00098 sigaction(SIGALRM, &act, 0);
00099 #ifdef SIGTRAP
00100 sigaddset(&act.sa_mask, SIGTRAP);
00101 #endif
00102 #ifdef SIGXFSZ
00103 sigaddset(&act.sa_mask, SIGXFSZ);
00104 sigaction(SIGXFSZ, &act, 0);
00105 #endif
00106
00107 #ifdef SIGWINCH
00108 sigaddset(&act.sa_mask, SIGWINCH);
00109 sigaction(SIGWINCH, &act, 0);
00110 #endif
00111 sigaction(SIGPIPE, &act, 0);
00112 #ifdef SIGTRAP
00113 sigaction(SIGTRAP, &act, 0);
00114 #endif
00115
00116 act.sa_handler = sighup_handler;
00117 sigemptyset(&act.sa_mask);
00118 sigaddset(&act.sa_mask, SIGHUP);
00119 sigaction(SIGHUP, &act, 0);
00120
00121 act.sa_handler = sigint_handler;
00122 sigaddset(&act.sa_mask, SIGINT);
00123 sigaction(SIGINT, &act, 0);
00124
00125 act.sa_handler = sigterm_handler;
00126 sigaddset(&act.sa_mask, SIGTERM);
00127 sigaction(SIGTERM, &act, 0);
00128
00129 act.sa_handler = sigusr1_handler;
00130 sigaddset(&act.sa_mask, SIGUSR1);
00131 sigaction(SIGUSR1, &act, 0);
00132
00133 act.sa_handler = sigchld_handler;
00134 sigaddset(&act.sa_mask, SIGCHLD);
00135 sigaction(SIGCHLD, &act, 0);
00136 }