From bd198cc78b1f9bc1dbfdaad075ca9c21b0f718b4 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 23 Jan 2025 01:05:25 -0600 Subject: [PATCH] Update: To the latest signal handling logic. --- data/build/stand_alone/config.h | 2 + sources/c/program/controller/main/common/type.h | 9 +---- sources/c/program/controller/main/signal.c | 52 +++---------------------- 3 files changed, 9 insertions(+), 54 deletions(-) diff --git a/data/build/stand_alone/config.h b/data/build/stand_alone/config.h index 0877bc5..3e426d0 100644 --- a/data/build/stand_alone/config.h +++ b/data/build/stand_alone/config.h @@ -1981,6 +1981,7 @@ #define _di_fl_iki_eki_read_ //#define _di_fl_iki_read_ //#define _di_fl_path_canonical_ +#define _di_fl_path_clean_ //#define _di_fl_print_debug_s_ //#define _di_fl_print_error_s_ //#define _di_fl_print_format_ @@ -2206,5 +2207,6 @@ //#define _di_fll_program_standard_set_up_ //#define _di_fll_program_standard_signal_handle_ //#define _di_fll_program_standard_signal_received_ +//#define _di_fll_program_standard_signal_received_wait_ #define _di_private_inline_f_print_to_error_ #define _di_private_inline_private_f_print_to_error_ diff --git a/sources/c/program/controller/main/common/type.h b/sources/c/program/controller/main/common/type.h index c75a9d5..44fe04f 100644 --- a/sources/c/program/controller/main/common/type.h +++ b/sources/c/program/controller/main/common/type.h @@ -23,10 +23,8 @@ extern "C" { * These program settings are often processed from the program arguments (often called the command line arguments). * * Properties: - * - flag: Flags passed to the main function. - * - * - status_signal: A status used eclusively by the threaded signal handler. - * - state: The state data used when processing the FSS data. + * - flag: Flags passed to the main function. + * - state: The state data used when processing the FSS data. * * - path_pid: The name of the program. * - path_setting: The long name of the program. @@ -34,8 +32,6 @@ extern "C" { #ifndef _di_controller_setting_t_ typedef struct { uint16_t flag; - - f_status_t status_signal; f_state_t state; f_string_dynamic_t path_pid; @@ -45,7 +41,6 @@ extern "C" { #define controller_setting_t_initialize \ { \ controller_main_flag_none_d, \ - F_okay, \ f_state_t_initialize, \ f_string_dynamic_t_initialize, \ f_string_dynamic_t_initialize, \ diff --git a/sources/c/program/controller/main/signal.c b/sources/c/program/controller/main/signal.c index 5b3f5c6..8968795 100644 --- a/sources/c/program/controller/main/signal.c +++ b/sources/c/program/controller/main/signal.c @@ -7,10 +7,11 @@ 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) return F_true; if (!((++main->program.signal_check) % controller_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { + 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); main->setting.state.status = F_status_set_error(F_interrupt); @@ -47,13 +48,6 @@ extern "C" { if (!main) return; - siginfo_t information; - f_number_unsigned_t failsafe = 0; - - memset(&information, 0, sizeof(siginfo_t)); - - main->program.signal_received = 0; - f_signal_set_empty(&main->program.signal.set); f_signal_set_add(F_signal_abort, &main->program.signal.set); f_signal_set_add(F_signal_broken_pipe, &main->program.signal.set); @@ -62,45 +56,9 @@ extern "C" { f_signal_set_add(F_signal_quit, &main->program.signal.set); f_signal_set_add(F_signal_termination, &main->program.signal.set); - if (main->program.signal.id == -1) { - main->setting.status_signal = f_signal_open(&main->program.signal); - - if (F_status_is_error(main->setting.status_signal)) { - main->program.signal_received = F_signal_abort; - - return; - } - } - - do { - memset(&information, 0, sizeof(siginfo_t)); - - main->setting.status_signal = f_signal_wait(&main->program.signal.set, &information); - - if (F_status_is_error(main->setting.status_signal) && F_status_set_fine(main->setting.status_signal) != F_interrupt) { - if (++failsafe >= controller_signal_check_failsafe_d) break; - } - - switch (information.si_signo) { - case F_signal_abort: - case F_signal_broken_pipe: - case F_signal_hangup: - case F_signal_interrupt: - case F_signal_quit: - case F_signal_termination: - main->program.signal_received = information.si_signo; - - break; - } - - failsafe = 0; - main->setting.status_signal = F_okay; - - } while (!main->program.signal_received); - - f_signal_close(&main->program.signal); + fll_program_standard_signal_received_wait(&main->program, controller_signal_check_failsafe_d); - if (F_status_is_error(main->setting.status_signal)) { + if (F_status_is_error(main->program.signal_status) && F_status_set_fine(main->program.signal_status) != F_interrupt) { main->program.signal_received = F_signal_abort; } } -- 1.8.3.1