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.
This commit is contained in:
parent
f3a2bed063
commit
76c90e1639
2 changed files with 5 additions and 4 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue