From ed5e4248dfdee27e2f59e3158e763b0d9b713670 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 22 Mar 2026 12:15:33 -0400 Subject: [PATCH] v0.2.4 - Fix SIGINT handling so Ctrl-C exits didactyl reliably --- README.md | 4 ++-- src/main.c | 27 +++++++++++++++++++++++---- src/main.h | 4 ++-- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 542e220..90c5665 100644 --- a/README.md +++ b/README.md @@ -54,11 +54,11 @@ Skills compose by adoption-list order (`10123`) and trigger tags carry runtime e Didactyl will support local inference, which is very privacy preserving. Remote inference does however have it's advantages, and in those cases Didactyl supports using Bitcoin Lightning and eCash inference providers. -## Current Status — v0.2.3 +## Current Status — v0.2.4 **Active build — this project is barely working. Experiment at your own risk.** -> Last release update: v0.2.3 — Silence unused static helper warnings after migration rollback reapply +> Last release update: v0.2.4 — Fix SIGINT handling so Ctrl-C exits didactyl reliably - Connects to configured relays with auto-reconnect and relay state transition logging - Publishes configured startup events per relay as each relay becomes connected diff --git a/src/main.c b/src/main.c index 08c63fd..ffcf396 100644 --- a/src/main.c +++ b/src/main.c @@ -56,8 +56,15 @@ static void on_self_skill_eose_load_triggers(int event_count, void* user_data) { } } +static volatile sig_atomic_t g_sigint_count = 0; + static void signal_handler(int signum) { - (void)signum; + if (signum == SIGINT) { + g_sigint_count++; + if (g_sigint_count >= 2) { + _exit(130); + } + } g_running = 0; } @@ -1442,9 +1449,21 @@ int main(int argc, char** argv) { } } - signal(SIGINT, signal_handler); - signal(SIGTERM, signal_handler); - signal(SIGPIPE, SIG_IGN); + struct sigaction sa; + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = signal_handler; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + + (void)sigaction(SIGINT, &sa, NULL); + (void)sigaction(SIGTERM, &sa, NULL); + + struct sigaction sa_pipe; + memset(&sa_pipe, 0, sizeof(sa_pipe)); + sa_pipe.sa_handler = SIG_IGN; + sigemptyset(&sa_pipe.sa_mask); + sa_pipe.sa_flags = 0; + (void)sigaction(SIGPIPE, &sa_pipe, NULL); int http_api_started = 0; if (cfg.api.enabled) { diff --git a/src/main.h b/src/main.h index e31a68d..5adb56f 100644 --- a/src/main.h +++ b/src/main.h @@ -12,8 +12,8 @@ // Using DIDACTYL_ prefix to avoid conflicts with nostr_core_lib VERSION macros #define DIDACTYL_VERSION_MAJOR 0 #define DIDACTYL_VERSION_MINOR 2 -#define DIDACTYL_VERSION_PATCH 3 -#define DIDACTYL_VERSION "v0.2.3" +#define DIDACTYL_VERSION_PATCH 4 +#define DIDACTYL_VERSION "v0.2.4" // Agent metadata #define DIDACTYL_NAME "Didactyl"