From 76c90e1639ee900fca4fc858260f0078ba32b9b1 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Fri, 2 Aug 2013 23:46:19 +0200 Subject: [PATCH] Non-zero exit code when reloading config file fails after SIGHUP. When reloading the configuration file via the tinc command, the user will get an error message if reloading has failed. However, no such warning exists when sending a HUP signal. Previously, tincd would exit in both cases, but with a zero exit code. Now it will exit with code 1 when reloading fails after a SIGHUP, but tincd will keep running if it is signaled via the tinc command. Instead, the tinc command will exit with a non-zero exit code. --- src/conf.c | 3 ++- src/net.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/conf.c b/src/conf.c index 71e45092..3c645197 100644 --- a/src/conf.c +++ b/src/conf.c @@ -373,9 +373,10 @@ bool read_server_config(void) { read_config_options(config_tree, NULL); xasprintf(&fname, "%s" SLASH "tinc.conf", confbase); + errno = 0; x = read_config_file(config_tree, fname); - if(!x) + if(!x && errno) logger(DEBUG_ALWAYS, LOG_ERR, "Failed to read `%s': %s", fname, strerror(errno)); free(fname); diff --git a/src/net.c b/src/net.c index 0b43d5ac..bf6cfcf1 100644 --- a/src/net.c +++ b/src/net.c @@ -298,7 +298,8 @@ static void sigterm_handler(void *data) { static void sighup_handler(void *data) { logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s signal", strsignal(((signal_t *)data)->signum)); reopenlogger(); - reload_configuration(); + if(reload_configuration()) + exit(1); } static void sigalrm_handler(void *data) { @@ -316,8 +317,7 @@ int reload_configuration(void) { init_configuration(&config_tree); if(!read_server_config()) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unable to reread configuration file, exitting."); - event_exit(); + logger(DEBUG_ALWAYS, LOG_ERR, "Unable to reread configuration file."); return EINVAL; }