From b4ea2f4da2df83335e4b1d3f5e3218d7f48731ee Mon Sep 17 00:00:00 2001 From: Jason Dellaluce Date: Thu, 6 Oct 2022 14:37:40 +0000 Subject: [PATCH] fix(userspace/falco): stabilize termination signal handler Signed-off-by: Jason Dellaluce --- userspace/falco/app_actions/create_signal_handlers.cpp | 5 ++--- userspace/falco/application.cpp | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/userspace/falco/app_actions/create_signal_handlers.cpp b/userspace/falco/app_actions/create_signal_handlers.cpp index 4a677fcc..d190f1ca 100644 --- a/userspace/falco/app_actions/create_signal_handlers.cpp +++ b/userspace/falco/app_actions/create_signal_handlers.cpp @@ -75,15 +75,14 @@ bool application::create_handler(int sig, void (*func)(int), run_result &ret) application::run_result application::create_signal_handlers() { run_result ret; + s_app = *this; if(! create_handler(SIGINT, ::signal_callback, ret) || ! create_handler(SIGTERM, ::signal_callback, ret) || ! create_handler(SIGUSR1, ::reopen_outputs, ret) || ! create_handler(SIGHUP, ::restart_falco, ret)) { - return ret; + s_app = dummy; } - - s_app = *this; return ret; } diff --git a/userspace/falco/application.cpp b/userspace/falco/application.cpp index 6e095269..43933993 100644 --- a/userspace/falco/application.cpp +++ b/userspace/falco/application.cpp @@ -137,7 +137,6 @@ bool application::run(std::string &errstr, bool &restart) std::bind(&application::print_ignored_events, this), std::bind(&application::print_syscall_events, this), std::bind(&application::load_config, this), - std::bind(&application::create_signal_handlers, this), std::bind(&application::print_plugin_info, this), std::bind(&application::list_plugins, this), std::bind(&application::load_plugins, this), @@ -148,6 +147,7 @@ bool application::run(std::string &errstr, bool &restart) std::bind(&application::validate_rules_files, this), std::bind(&application::load_rules_files, this), std::bind(&application::print_support, this), + std::bind(&application::create_signal_handlers, this), std::bind(&application::attach_inotify_signals, this), std::bind(&application::create_requested_paths, this), std::bind(&application::daemonize, this),