From 343f2a8a6148b8004d6f4d74fb779b4f30c9686a Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 15 Nov 2026 03:11:22 +0100 Subject: M1-M5: sessions, six tools, approvals, prompt, Ctrl-C, target gate - append-only JSONL sessions with --continue/--session; reasoning stored, stripped on replay - read/write/edit/grep/glob + bash with timeout and capped output - diff-preview approval for the first edit of a session, per-call approval for bash - system prompt frozen per session with AGENTS.md snapshot and change warning - SIGINT aborts the turn, second Ctrl-C exits - glibc gate ignores weak symbols; verified in linux/386 debian:12 - acceptance test (calculator in C) passes on both x86-64 and i386 --- src/signal.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/signal.rs (limited to 'src/signal.rs') diff --git a/src/signal.rs b/src/signal.rs new file mode 100644 index 0000000..8705660 --- /dev/null +++ b/src/signal.rs @@ -0,0 +1,23 @@ +use std::sync::atomic::{AtomicBool, Ordering}; + +/// Set by the first Ctrl-C. Cleared between turns. +pub static CANCEL: AtomicBool = AtomicBool::new(false); + +extern "C" fn handler(_: libc::c_int) { + // First Ctrl-C aborts the turn. A second one is taken to mean "I really mean + // it" and leaves immediately; `_exit` is async-signal-safe, `exit` is not. + if CANCEL.swap(true, Ordering::SeqCst) { + unsafe { libc::_exit(130) } + } +} + +pub fn install() { + let handler: extern "C" fn(libc::c_int) = handler; + unsafe { + libc::signal(libc::SIGINT, handler as libc::sighandler_t); + } +} + +pub fn reset() { + CANCEL.store(false, Ordering::SeqCst); +} -- cgit v1.2.3