Changes in unix.c [5535a47:c467adc]
Legend:
- Unmodified
- Added
- Removed
-
unix.c
r5535a47 rc467adc 48 48 global_t global; /* Against global namespace pollution */ 49 49 50 static int signal_shutdown_pipe[2] = { -1, -1 }; 50 static struct { 51 int fd[2]; 52 int tag; 53 } shutdown_pipe = {{-1 , -1}, 0}; 54 51 55 static void sighandler_shutdown(int signal); 52 56 static void sighandler_crash(int signal); … … 156 160 sigaction(SIGSEGV, &sig, &old); 157 161 158 /* Use a pipe for SIGTERM/SIGINT so the actual signal handler doesn't do anything unsafe */ 159 if (pipe(signal_shutdown_pipe) == 0) { 160 b_input_add(signal_shutdown_pipe[0], B_EV_IO_READ, bitlbee_shutdown, NULL); 161 sig.sa_handler = sighandler_shutdown; 162 sigaction(SIGINT, &sig, &old); 163 sigaction(SIGTERM, &sig, &old); 164 } 162 sighandler_shutdown_setup(); 163 164 sig.sa_handler = sighandler_shutdown; 165 sigaction(SIGINT, &sig, &old); 166 sigaction(SIGTERM, &sig, &old); 165 167 166 168 if (!getuid() || !geteuid()) { … … 256 258 } 257 259 260 /* Set up a pipe for SIGTERM/SIGINT so the actual signal handler doesn't do anything unsafe */ 261 void sighandler_shutdown_setup() 262 { 263 if (shutdown_pipe.fd[0] != -1) { 264 /* called again from a forked process, clean up to avoid propagating the signal */ 265 b_event_remove(shutdown_pipe.tag); 266 close(shutdown_pipe.fd[0]); 267 close(shutdown_pipe.fd[1]); 268 } 269 270 if (pipe(shutdown_pipe.fd) == 0) { 271 shutdown_pipe.tag = b_input_add(shutdown_pipe.fd[0], B_EV_IO_READ, bitlbee_shutdown, NULL); 272 } 273 } 274 258 275 /* Signal handler for SIGTERM and SIGINT */ 259 276 static void sighandler_shutdown(int signal) … … 261 278 /* Write a single null byte to the pipe, just to send a message to the main loop. 262 279 * This gets handled by bitlbee_shutdown (the b_input_add callback for this pipe) */ 263 write(s ignal_shutdown_pipe[1], "", 1);280 write(shutdown_pipe.fd[1], "", 1); 264 281 } 265 282 … … 275 292 for (l = irc_connection_list; l; l = l->next) { 276 293 irc_t *irc = l->data; 294 sock_make_blocking(irc->fd); 277 295 write(irc->fd, message, len); 278 296 }
Note: See TracChangeset
for help on using the changeset viewer.