Skip to content

Give a signalled agent the exit code a shell would - #14

Merged
wilbeibi merged 1 commit into
mainfrom
agent-signal-exit
Sep 4, 2026
Merged

Give a signalled agent the exit code a shell would#14
wilbeibi merged 1 commit into
mainfrom
agent-signal-exit

Conversation

@wilbeibi

@wilbeibi wilbeibi commented Sep 4, 2026

Copy link
Copy Markdown
Owner

#13 passed the launched agent's exit code through, but a signal carries no exit code, so one ending was left behind:

$ catchup fork claude          # the agent is OOM-killed
catchup: signal: killed
$ echo $?
1

That is catchup's name over a death that was not catchup's — the attribution #13 removed everywhere else — and a wrapper learns nothing from the 1. It is also the shape #12's triage rule misreads: an agent told that "a non-zero exit from fork is the launched agent's own status" sees a catchup:-prefixed error here and files a bug.

A signalled agent now exits 128 plus the signal number, which is the answer a shell gives for the same death, so $? is 137 for a kill -9 and 139 for a segfault. The death still gets one line, because the agent had no chance to explain itself and the kernel says nothing to the terminal — but the line names the agent:

catchup: claude died: killed
catchup: claude died: terminated
catchup: claude died: segmentation fault

syscall.WaitStatus.Signaled() and .Signal() are defined on Windows and macOS as well as Linux, so this needs no build tags; on Windows a terminated process still carries an exit code and takes the existing path. Verified end to end with SIGKILL, SIGTERM and SIGSEGV (137/143/139); the new test skips on Windows.

Passing the agent's exit code through left one ending behind: a signal
carries no code, so an agent that was killed still came back as
`catchup: signal: killed` and exit 1 — catchup's name over a death that
was not catchup's, which is the attribution the previous commit removed
everywhere else. An agent following the skill's triage rule would file
that as a bug.

A signalled agent now exits 128 plus the number, the same answer a shell
gives for the same death, so a wrapper reads 137 for an OOM kill instead
of a bare 1. That death gets one line, because the agent had no chance to
explain itself and the kernel tells the terminal nothing — but the line
names the agent.

Claude-Session: https://claude.ai/code/session_01SSuFsifuVnFBU69q6ZzZyJ
@wilbeibi
wilbeibi merged commit 78dd812 into main Sep 4, 2026
2 checks passed
@wilbeibi
wilbeibi deleted the agent-signal-exit branch September 4, 2026 04:28
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