]> Kevux Git Server - control/commitdiff
Update: To the latest signal handling logic.
authorKevin Day <Kevin@kevux.org>
Thu, 23 Jan 2025 07:04:37 +0000 (01:04 -0600)
committerKevin Day <Kevin@kevux.org>
Thu, 23 Jan 2025 07:04:37 +0000 (01:04 -0600)
data/build/stand_alone/config.h
sources/c/program/control/main/common/type.h
sources/c/program/control/main/signal.c

index 48feefebede1a4045ca5d8a9cdba84fb917de88e..5493de571cbb5e4527e2bb0f03d5826259e8e841 100644 (file)
 //#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_
index e2910fe81368b6ed3375edf151089d0a13e44dd1..a8f260e16174422d9d73e6bb982ec2774981df93 100644 (file)
@@ -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, \
index 7daac73839488e36f7d81ae1d23a3e9233e30784..c99735a07b50a51c659ea66973d8eaecd30c9cd8 100644 (file)
@@ -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;
     }
   }