From: Kevin Day Date: Thu, 23 Jan 2025 07:04:37 +0000 (-0600) Subject: Update: To the latest signal handling logic. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=56a7103c5bbe487b787148177a63268253d3d811;p=control Update: To the latest signal handling logic. --- diff --git a/data/build/stand_alone/config.h b/data/build/stand_alone/config.h index 48feefe..5493de5 100644 --- a/data/build/stand_alone/config.h +++ b/data/build/stand_alone/config.h @@ -1954,5 +1954,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/control/main/common/type.h b/sources/c/program/control/main/common/type.h index e2910fe..a8f260e 100644 --- a/sources/c/program/control/main/common/type.h +++ b/sources/c/program/control/main/common/type.h @@ -111,9 +111,7 @@ extern "C" { * - flag: Flags passed to the main function. * - action: The action type code. * - size_write: The write size of a packet request or response. - * - * - status_signal: A status used eclusively by the threaded signal handler. - * - state: The state data used when processing the data. + * - state: The state data used when processing the data. * * - range: A range for any particular use. * - socket: A socket used to connect to the controller. @@ -128,8 +126,6 @@ extern "C" { uint16_t flag; uint8_t action; f_number_unsigned_t size_write; - - f_status_t status_signal; f_state_t state; f_range_t range; @@ -146,7 +142,6 @@ extern "C" { control_main_flag_none_d, \ 0, \ 0, \ - F_okay, \ f_state_t_initialize, \ f_range_t_initialize, \ f_socket_t_initialize, \ diff --git a/sources/c/program/control/main/signal.c b/sources/c/program/control/main/signal.c index 7daac73..c99735a 100644 --- a/sources/c/program/control/main/signal.c +++ b/sources/c/program/control/main/signal.c @@ -7,10 +7,11 @@ extern "C" { #if !defined(_di_control_signal_check_) && defined(_di_thread_support_) f_status_t control_signal_check(control_main_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) % control_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 >= control_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, control_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; } }