diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-15 03:11:22 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-15 03:11:22 +0100 |
| commit | 343f2a8a6148b8004d6f4d74fb779b4f30c9686a (patch) | |
| tree | 2ea1ddab346565309da644517c3478d2a9096e55 /src/signal.rs | |
| parent | M0: streaming provider, SSE decoder, mock provider, i686 build gate (diff) | |
| download | agent686-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 'src/signal.rs')
| -rw-r--r-- | src/signal.rs | 23 |
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 @@ | |||
| 1 | use std::sync::atomic::{AtomicBool, Ordering}; | ||
| 2 | |||
| 3 | /// Set by the first Ctrl-C. Cleared between turns. | ||
| 4 | pub static CANCEL: AtomicBool = AtomicBool::new(false); | ||
| 5 | |||
| 6 | extern "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 | |||
| 14 | pub 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 | |||
| 21 | pub fn reset() { | ||
| 22 | CANCEL.store(false, Ordering::SeqCst); | ||
| 23 | } | ||
