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

index 784777b726bee31970e85a184bc04d626905d764..87c9e4ed2892f9e87339a377ebbeb6ed19f74de5 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;
     }
 
@@ -98,6 +102,10 @@ extern "C" {
       main->setting.state.status = F_status_set_error(F_data_not);
     }
 
+    if (main->program.signal_received) {
+      fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
+    }
+
     if (F_status_is_error(main->setting.state.status)) return;
 
     main->setting.state.status = F_okay;
index 6a577a7749aa9fe22aced2f123879d7e7eeff08c..d62a2597a00d0566f2c3fb67b2b1f9aedbdf9657 100644 (file)
@@ -11,9 +11,7 @@ extern "C" {
     if (main->program.signal_received) return F_true;
 
     if (!((++main->program.signal_check) % control_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;
@@ -32,8 +30,6 @@ extern "C" {
     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;