summaryrefslogtreecommitdiffstats
path: root/src/signal.rs
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-15 03:11:22 +0100
committersalmonik <salmonik@tuta.io>2026-11-15 03:11:22 +0100
commit343f2a8a6148b8004d6f4d74fb779b4f30c9686a (patch)
tree2ea1ddab346565309da644517c3478d2a9096e55 /src/signal.rs
parentM0: streaming provider, SSE decoder, mock provider, i686 build gate (diff)
downloadagent686-343f2a8a6148b8004d6f4d74fb779b4f30c9686a.tar.gz
agent686-343f2a8a6148b8004d6f4d74fb779b4f30c9686a.zip
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
Diffstat (limited to '')
-rw-r--r--src/signal.rs23
1 files changed, 23 insertions, 0 deletions
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 @@
1use std::sync::atomic::{AtomicBool, Ordering};
2
3/// Set by the first Ctrl-C. Cleared between turns.
4pub static CANCEL: AtomicBool = AtomicBool::new(false);
5
6extern "C" fn handler(_: libc::c_int) {
7 // First Ctrl-C aborts the turn. A second one is taken to mean "I really mean
8 // it" and leaves immediately; `_exit` is async-signal-safe, `exit` is not.
9 if CANCEL.swap(true, Ordering::SeqCst) {
10 unsafe { libc::_exit(130) }
11 }
12}
13
14pub fn install() {
15 let handler: extern "C" fn(libc::c_int) = handler;
16 unsafe {
17 libc::signal(libc::SIGINT, handler as libc::sighandler_t);
18 }
19}
20
21pub fn reset() {
22 CANCEL.store(false, Ordering::SeqCst);
23}