From 56ff55072d8042776b59a98c2497b351c762e01e Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 27 Jan 2025 22:45:43 -0600 Subject: [PATCH] Update: Improve signal handling code. Move the `fll_program_print_signal_received()` calls to the main program to help ensure consistent printing at the end of the program. - Note: I am not certain if I want this instead in the main() function or not and I opted not to do so for now. --- sources/c/program/controller/main/process.c | 14 ++++++++------ sources/c/program/controller/main/signal.c | 8 ++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/sources/c/program/controller/main/process.c b/sources/c/program/controller/main/process.c index caba90e..c9dc186 100644 --- a/sources/c/program/controller/main/process.c +++ b/sources/c/program/controller/main/process.c @@ -22,6 +22,10 @@ extern "C" { fll_program_print_copyright(&main->program.message, fll_program_copyright_year_author_s); } + if (main->program.signal_received) { + fll_program_print_signal_received(&main->program.warning, main->program.signal_received); + } + return; } @@ -145,16 +149,14 @@ extern "C" { if (main->thread.signal) { main->program.signal_received = main->thread.signal; } - - if (main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); - } - - fll_program_print_signal_received(&main->program.warning, main->program.signal_received); } else { main->setting.state.status = F_status_is_error(status) ? F_status_set_error(F_failure) : F_okay; } + + if (main->program.signal_received) { + fll_program_print_signal_received(&main->program.warning, main->program.signal_received); + } } #endif // _di_controller_process_ diff --git a/sources/c/program/controller/main/signal.c b/sources/c/program/controller/main/signal.c index 8968795..7db1558 100644 --- a/sources/c/program/controller/main/signal.c +++ b/sources/c/program/controller/main/signal.c @@ -11,9 +11,7 @@ extern "C" { if (main->program.signal_received) return F_true; if (!((++main->program.signal_check) % controller_signal_check_d)) { - if (F_status_set_fine(fll_program_standard_signal_received(&main->program)) == F_interupt) { - fll_program_print_signal_received(&main->program.warning, main->program.signal_received); - + if (F_status_set_fine(fll_program_standard_signal_received(&main->program)) == F_interrupt) { main->setting.state.status = F_status_set_error(F_interrupt); return F_true; @@ -29,11 +27,9 @@ extern "C" { #if !defined(_di_controller_signal_check_) && !defined(_di_thread_support_) f_status_t controller_signal_check(controller_t * const main) { - if (!main || main->program.signal.id == -1) return F_false; + if (!main) return F_false; if (main->program.signal_received) { - fll_program_print_signal_received(&main->program.warning, main->program.signal_received); - main->setting.state.status = F_status_set_error(F_interrupt); return F_true; -- 1.8.3.1