diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-07 11:45:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-07 11:45:55 +0000 |
commit | a8220ab2d293bb7f4b014b79d16b2fb05090fa93 (patch) | |
tree | 77f0a30f016c0925cf7ee9292e644bba183c2774 /daemon/signals.c | |
parent | Adding upstream version 1.19.0. (diff) | |
download | netdata-a8220ab2d293bb7f4b014b79d16b2fb05090fa93.tar.xz netdata-a8220ab2d293bb7f4b014b79d16b2fb05090fa93.zip |
Adding upstream version 1.29.0.upstream/1.29.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'daemon/signals.c')
-rw-r--r-- | daemon/signals.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/daemon/signals.c b/daemon/signals.c index 5378b04e5..9e30bf19d 100644 --- a/daemon/signals.c +++ b/daemon/signals.c @@ -9,7 +9,7 @@ typedef enum signal_action { NETDATA_SIGNAL_IGNORE, NETDATA_SIGNAL_EXIT_CLEANLY, NETDATA_SIGNAL_SAVE_DATABASE, - NETDATA_SIGNAL_LOG_ROTATE, + NETDATA_SIGNAL_REOPEN_LOGS, NETDATA_SIGNAL_RELOAD_HEALTH, NETDATA_SIGNAL_FATAL, NETDATA_SIGNAL_CHILD, @@ -25,7 +25,7 @@ static struct { { SIGINT , "SIGINT", 0, NETDATA_SIGNAL_EXIT_CLEANLY }, { SIGQUIT, "SIGQUIT", 0, NETDATA_SIGNAL_EXIT_CLEANLY }, { SIGTERM, "SIGTERM", 0, NETDATA_SIGNAL_EXIT_CLEANLY }, - { SIGHUP, "SIGHUP", 0, NETDATA_SIGNAL_LOG_ROTATE }, + { SIGHUP, "SIGHUP", 0, NETDATA_SIGNAL_REOPEN_LOGS }, { SIGUSR1, "SIGUSR1", 0, NETDATA_SIGNAL_SAVE_DATABASE }, { SIGUSR2, "SIGUSR2", 0, NETDATA_SIGNAL_RELOAD_HEALTH }, { SIGBUS, "SIGBUS", 0, NETDATA_SIGNAL_FATAL }, @@ -111,6 +111,21 @@ void signals_init(void) { } } +void signals_restore_SIGCHLD(void) +{ + struct sigaction sa; + + if (reaper_enabled == 0) + return; + + sa.sa_flags = 0; + sigfillset(&sa.sa_mask); + sa.sa_handler = signal_handler; + + if(sigaction(SIGCHLD, &sa, NULL) == -1) + error("SIGNAL: Failed to change signal handler for: SIGCHLD"); +} + void signals_reset(void) { struct sigaction sa; sigemptyset(&sa.sa_mask); @@ -221,33 +236,35 @@ void signals_handle(void) { case NETDATA_SIGNAL_RELOAD_HEALTH: error_log_limit_unlimited(); info("SIGNAL: Received %s. Reloading HEALTH configuration...", name); - health_reload(); error_log_limit_reset(); + execute_command(CMD_RELOAD_HEALTH, NULL, NULL); break; case NETDATA_SIGNAL_SAVE_DATABASE: error_log_limit_unlimited(); info("SIGNAL: Received %s. Saving databases...", name); - rrdhost_save_all(); - info("Databases saved."); error_log_limit_reset(); + execute_command(CMD_SAVE_DATABASE, NULL, NULL); break; - case NETDATA_SIGNAL_LOG_ROTATE: + case NETDATA_SIGNAL_REOPEN_LOGS: error_log_limit_unlimited(); info("SIGNAL: Received %s. Reopening all log files...", name); - reopen_all_log_files(); error_log_limit_reset(); + execute_command(CMD_REOPEN_LOGS, NULL, NULL); break; case NETDATA_SIGNAL_EXIT_CLEANLY: error_log_limit_unlimited(); info("SIGNAL: Received %s. Cleaning up to exit...", name); + commands_exit(); netdata_cleanup_and_exit(0); exit(0); + break; case NETDATA_SIGNAL_FATAL: fatal("SIGNAL: Received %s. netdata now exits.", name); + break; case NETDATA_SIGNAL_CHILD: debug(D_CHILDS, "SIGNAL: Received %s. Reaping...", name); |