]> Kevux Git Server - kevux-tools/commitdiff
Update: The threaded signal handler to avoid signal id races.
authorKevin Day <Kevin@kevux.org>
Fri, 24 Jan 2025 03:00:15 +0000 (21:00 -0600)
committerKevin Day <Kevin@kevux.org>
Fri, 24 Jan 2025 03:00:15 +0000 (21:00 -0600)
Apply the same anti-race improvements implemented on the non-threaded signal checker to the threaded signal checker.

Still check for a negative id to prevent the signal message from being printed more than once.

sources/c/program/kevux/tools/remove/main/signal.c
sources/c/program/kevux/tools/tacocat/main/signal.c

index 1d1a708881bcae46dcc489ad2c4f4aacc0943912..aead2f61c1614e37cbebab7051ce1d43d6c0aeb8 100644 (file)
@@ -23,8 +23,15 @@ extern "C" {
 #if !defined(_di_kt_remove_signal_check_) && !defined(_di_thread_support_)
   f_status_t kt_remove_signal_check(kt_remove_main_t * const main) {
 
-    if (!main || main->program.signal.id == -1) return F_false;
-    if (main->program.signal_received) return F_true;
+    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;
+    }
 
     return F_false;
   }
index b3db7fa021d2fa3e292af64ac62232cfb765ab3f..2d3c95b213c664c347d039bea3c8ab0638a25554 100644 (file)
@@ -23,8 +23,15 @@ extern "C" {
 #if !defined(_di_kt_tacocat_signal_check_) && !defined(_di_thread_support_)
   f_status_t kt_tacocat_signal_check(kt_tacocat_main_t * const main) {
 
-    if (!main || main->program.signal.id == -1) return F_false;
-    if (main->program.signal_received) return F_true;
+    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;
+    }
 
     return F_false;
   }