# HG changeset patch # User Timo Sirainen # Date 1150543450 -10800 # Node ID f0ac35961ae24c35fe36438d5dcc713dcbc193bb # Parent 16b28625cb79f5ed5c7e6ec941cff958b56d09a2 Make sure the process dies when the master process dies. diff -r 16b28625cb79 -r f0ac35961ae2 src/dict/main.c --- a/src/dict/main.c Fri Jun 16 21:37:06 2006 +0300 +++ b/src/dict/main.c Sat Jun 17 14:24:10 2006 +0300 @@ -13,12 +13,14 @@ #include "module-dir.h" #include +#include #include #define DICT_MASTER_LISTENER_FD 3 struct ioloop *ioloop; +static struct io *log_io; static struct module *modules; static struct dict_server *dict_server; @@ -31,6 +33,11 @@ io_loop_stop(ioloop); } +static void log_error_callback(void *context __attr_unused__) +{ + io_loop_stop(ioloop); +} + static void drop_privileges(void) { /* Log file or syslog opening probably requires roots */ @@ -58,6 +65,9 @@ lib_signals_ignore(SIGPIPE); lib_signals_set_handler(SIGALRM, FALSE, NULL, NULL); + /* If master dies, the log fd gets closed and we'll quit */ + log_io = io_add(STDERR_FILENO, IO_ERROR, log_error_callback, NULL); + dict_client_register(); dict_sql_register(); @@ -74,6 +84,7 @@ static void main_deinit(void) { + io_remove(&log_io); dict_server_deinit(dict_server); module_dir_unload(&modules);