Skip to content

Abnormal app exit leaves orphaned claude fleet; restore double-resumes their sessions #100

Description

@gi11es

Bug

When Deckard dies abnormally (killed / crash — anything that skips graceful teardown), all claude child processes survive as orphans (they ignore the PTY hangup), and on relaunch session restore spawns fresh claude --resume processes for the same session IDs. Result:

  • Two live claude processes resuming the same session, both appending to the same session .jsonl (observed: an orphan from a 2-day-old app death plus the current instance's resume of the same session — the session file's mtime moved with no visible new entries).
  • The orphan fleet silently burns memory/CPU and holds MCP server connections (Slack/Notion etc. were still connected on 2-day-old orphans).
  • Observed scale: 41 orphaned claude processes (plus their MCP children) from a single abnormal exit, invisible to the user.

Repro

  1. Run Deckard with many Claude tabs.
  2. kill -9 the Deckard process.
  3. Relaunch. ps -axo pid,ppid,command | awk '$2==1' shows the old fleet still alive while the new instance resumes the same sessions.

Expected

At most one live claude per session; no invisible process fleet after an app death.

Proposed fix

Record spawned shell PIDs (with process start time to guard against PID reuse) in app support state. On launch, before restore: for each recorded PID that is still alive and now orphaned (ppid == 1, matching start time), kill it, then respawn. Optionally also warn when --resume targets a session that another live process already has open.

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