]> Kevux Git Server - controller/commitdiff
Update: Improve signal handling code.
authorKevin Day <Kevin@kevux.org>
Tue, 28 Jan 2025 04:45:43 +0000 (22:45 -0600)
committerKevin Day <Kevin@kevux.org>
Tue, 28 Jan 2025 04:45:43 +0000 (22:45 -0600)
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
sources/c/program/controller/main/signal.c

index caba90eb7ebdf746687ac6226235eac7b0214170..c9dc186426aceecd747a54bb751b410c01adb9fb 100644 (file)
@@ -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_
 
index 8968795cf05604444cb5ff3758cbb85d7276a1a4..7db1558edfe00e1598ffeef10a3477a0c5783e53 100644 (file)
@@ -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;