-
Notifications
You must be signed in to change notification settings - Fork 5
Killing parent process does not abort sidecar session — orphaned sessions accumulate #20
Copy link
Copy link
Open
Description
Description
When a parent bash task is killed (via TaskStop, kill, or SIGTERM), the underlying sidecar session continues running. Orphaned sessions accumulate in sidecar list --status running and consume API resources.
Steps to Reproduce
- Launch multiple sidecars in background:
sidecar start --model gemini-pro --no-ui --prompt "Task 1" & sidecar start --model gemini-pro --no-ui --prompt "Task 2" & sidecar start --model gemini-pro --no-ui --prompt "Task 3" &
- Kill the parent bash processes (e.g.,
kill %1 %2 %3) - Check sidecar list:
All 3 sessions still show as
sidecar list --status running
running
Expected Behavior
Killing the parent process should signal the sidecar to abort (e.g., via SIGTERM handler that calls session abort).
Actual Behavior
Sidecar sessions are orphaned. Must manually run sidecar abort <id> for each one.
Impact
In our test session, we accumulated 3 orphaned Gemini Pro sessions that were consuming OpenRouter API credits while doing nothing useful. Users launching multiple parallel sidecars (the documented multi-LLM workflow) are especially likely to hit this.
Suggestion
- Register a SIGTERM/SIGINT handler in the sidecar CLI that aborts the OpenCode session on exit
- Alternatively, implement a heartbeat mechanism where the sidecar session checks if its parent is still alive
- Consider adding a
sidecar abort --allconvenience command for cleanup
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels