Background task reports exit code 0 when process is killed
Resolved 💬 2 comments Opened Mar 23, 2026 by chriswithers-fuse Closed Apr 21, 2026
Description
When a background task (started via run_in_background) is killed by the user, the task completion notification reports exit_code: 0 and status: completed. This makes killed tasks indistinguishable from successful ones.
Steps to reproduce
- Start a long-running command as a background task (e.g. a full-repo lint)
- Kill/interrupt the process before it completes
- Observe the task notification — it reports exit code 0 and status "completed"
Expected behavior
A killed process should report either:
- A non-zero exit code (e.g. 137 for SIGKILL, 130 for SIGINT), or
- A distinct status like
killedorinterruptedrather thancompleted
Actual behavior
The notification reports exit_code: 0 and status: completed, which is identical to a successful run.
Impact
Claude trusts the exit code to determine success/failure. When a killed task is reported as exit code 0, Claude will incorrectly tell the user that the task succeeded. The only way to catch this is to read the output file and notice it's truncated/incomplete — but there's no signal that this is necessary.
Environment
- Claude Code CLI
- macOS (Darwin 25.3.0)
- Model: claude-opus-4-6
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗