ProcessReaper
Defined in: src/process-reaper.ts:230
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ProcessReaper(
probes?):ProcessReaper
Defined in: src/process-reaper.ts:231
Parameters
Section titled “Parameters”probes?
Section titled “probes?”ReaperProbes = defaultProbes
Returns
Section titled “Returns”ProcessReaper
Methods
Section titled “Methods”detect()
Section titled “detect()”detect(
s):Leftover[]
Defined in: src/process-reaper.ts:234
Detect surviving leftovers for a session (classes 2 + 3).
Parameters
Section titled “Parameters”claudeSessionId
Section titled “claudeSessionId”string
isolated
Section titled “isolated”boolean
worktreePath
Section titled “worktreePath”string
Returns
Section titled “Returns”Leftover[]
reap()
Section titled “reap()”reap(
leftovers):void
Defined in: src/process-reaper.ts:315
Best-effort terminate each leftover (kill pid / run counter-command).
Parameters
Section titled “Parameters”leftovers
Section titled “leftovers”Leftover[]
Returns
Section titled “Returns”void
stopListenersOnPort()
Section titled “stopListenersOnPort()”stopListenersOnPort(
worktreePath,port,signal?):number
Defined in: src/process-reaper.ts:292
Signal every process under worktreePath that is currently listening on
exactly port, to terminate it. Excludes the shepherd process itself and
the claude agent. Returns the count of processes signalled (a signals-SENT
count — NOT a death confirmation; a process may ignore the signal or take
time to exit). Used by preview stop (idle-stop sends SIGTERM then escalates
to SIGKILL; force-stop sends SIGKILL).
SCOPE: only the process actually LISTENING on port is signalled — that is
the RAM-heavy bundler/server (Vite/Next/esbuild/node), so the bulk of memory
is reclaimed. A lightweight parent WRAPPER that merely spawned it (e.g.
npm run dev → vite) is not under this port and may linger holding its own
(small) footprint until the agent’s shell reaps it. We deliberately don’t
walk the process tree: the wrapper is often the agent’s own backgrounded job,
and killing up the tree risks disrupting the agent’s pane/job control — the
exact harm the opt-in, agent-idle-gated design avoids.
Parameters
Section titled “Parameters”worktreePath
Section titled “worktreePath”string
number
signal?
Section titled “signal?”Signals = "SIGTERM"
Returns
Section titled “Returns”number