Skip to content

Killing parent process does not abort sidecar session — orphaned sessions accumulate #20

@ellisjr

Description

@ellisjr

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

  1. 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" &
  2. Kill the parent bash processes (e.g., kill %1 %2 %3)
  3. Check sidecar list:
    sidecar list --status running
    All 3 sessions still show as 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 --all convenience command for cleanup

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions