Skip to content

feat(interpreter): deliver signals the shell sends itself - #2608

Merged
chaliy merged 1 commit into
mainfrom
claude/kill-self
Oct 8, 2026
Merged

chaliy merged 1 commit into
mainfrom
claude/kill-self

Conversation

@chaliy

@chaliy chaliy commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Requested by Михайло · project thread

What changed

kill -SIG $$, the shell signalling itself, is now delivered instead of being dropped:

  • With a trap set for that signal, the handler runs, under any spelling trap accepts (TERM, SIGTERM, 15), and an exit inside the handler ends the script.
  • With no handler, the default action ends the script with status 128 + signal: kill -9 $$ gives 137, kill -TERM $$ 143, kill -INT $$ 130.
  • Signals whose default action is to be ignored (CHLD, URG, WINCH, CONT) change nothing, and kill -0 $$ still only tests for the process.

Why

Debian-oracle cases exit-codes-signals and trap-signal-self. A script that ends itself with kill -TERM $$ after a failed check, or that uses trap ... USR1; kill -USR1 $$ to run a handler, carried on as if nothing had happened and exited 0.

Before / After

Script Before After (matches bash)
kill -9 $$; echo after prints after, exits 0 exits 137, after not run
kill -TERM $$ exits 0 exits 143
trap 'echo caught' TERM; kill -TERM $$; echo after after caught, then after
trap 'echo bye; exit 143' TERM; kill -TERM $$ nothing, exit 0 bye, exit 143
kill -0 $$; echo $? 0 unchanged

New spec file kill-self.test.sh (4 cases), verified against bash 5.2.

Risk

Medium-low. The kill builtin reports it through a new SignalSelf side effect, so the interpreter decides; nothing else changes about kill. The ERR-trap runner was refactored onto the shared handler-runner this needed, with the same behavior. L-SIG-001 is narrowed rather than removed: no signal can arrive from outside the sandbox, and its evidence test now asserts the new behavior.

Checklist

  • Failing spec first, verified against real bash
  • cargo test -p bashkit --lib, --test integration, bash_comparison (2903 cases)
  • cargo clippy --all-targets -D warnings, cargo fmt --check, just check-okf
  • knowledge (log.md, limitations L-SIG-001) updated

https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA


Generated by Claude Code

@chaliy chaliy self-assigned this Oct 7, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit c0b17f7 Commit Preview URL

Branch Preview URL
Oct 08 2026, 01:46 AM

kill -SIG $$ now runs that signal's trap, or ends the script with
128 + signal when no handler is set. It used to be a silent no-op.

Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
@chaliy
chaliy merged commit 1adb841 into main Oct 8, 2026
46 checks passed
@chaliy
chaliy deleted the claude/kill-self branch October 8, 2026 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant