From b7996fecd7c9c840bf14d1e8858373cc51b768e4 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 23 Jan 2025 21:00:15 -0600 Subject: [PATCH] Update: The threaded signal handler to avoid signal id races. 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 | 11 +++++++++-- sources/c/program/kevux/tools/tacocat/main/signal.c | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/sources/c/program/kevux/tools/remove/main/signal.c b/sources/c/program/kevux/tools/remove/main/signal.c index 1d1a708..aead2f6 100644 --- a/sources/c/program/kevux/tools/remove/main/signal.c +++ b/sources/c/program/kevux/tools/remove/main/signal.c @@ -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; } diff --git a/sources/c/program/kevux/tools/tacocat/main/signal.c b/sources/c/program/kevux/tools/tacocat/main/signal.c index b3db7fa..2d3c95b 100644 --- a/sources/c/program/kevux/tools/tacocat/main/signal.c +++ b/sources/c/program/kevux/tools/tacocat/main/signal.c @@ -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; } -- 1.8.3.1