You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Deleting a worktree environment leaves its processes running #1647
Deleting a bb worktree environment removes the directory but does not kill the processes started inside it. They survive with a working directory that no longer exists, and nothing reaps them.
Measured
On a 10-core Mac, 2026-08-14:
40 removed environments still held 190 live processes and 1.75 GB RSS
swap at 94%, kernel_task at 57% CPU on paging alone, load near 20
every process-holding environment was a deleted one; none of the 8 live worktrees held any
Reproduction
Create a worktree environment in a project with a dev server (next dev, vite, etc.)
Let the server start
Delete the environment
The server process is still running, with cwd pointing at the deleted path
Suggested fix
Kill the process group on environment teardown. Processes started in an environment are already associated with it; the teardown path just doesn't signal them.
Workaround in use
An hourly local sweeper that reaps processes whose cwd is a deleted environment path. That is a workaround — a machine without it inherits the leak, and the leak is what drove the box into swap.
Evidence from #1769 (closed as duplicate): on bb 0.38.0 / macOS 26 one machine had 40 destroyed environments still holding 190 live processes and 1.75 GB RSS, swap at 94%, load ~20 on 10 cores. Every process-holding environment was a deleted one; none of the 8 live environments had orphans. A claude provider process was alive 12h46m after its environment was destroyed. Also related: #1660, #1604, #1363.
Root cause (short): RuntimeManager.destroyEnvironment only SIGTERM/SIGKILLs the direct provider bridge pid and SIGHUPs the terminal shell pid (spawned in the daemon's own process group, no group signal, no cwd sweep) before git worktree remove --force, so anything those children detached (nohup dev servers, background jobs, MCP servers after a force-kill, or processes from a pre-restart daemon) survives with a deleted cwd and is never reaped.
Linked PR review:Kill processes left in a destroyed worktree environment #1696 → REQUEST CHANGES (minor) — killProcessesWithCwdUnder is ownership-agnostic: it SIGTERM/SIGKILLs any user process whose cwd is inside the workspace (demonstrated with a non-bb setsid sleep rooted in the worktree, pid 1641293 reaped), i.e. a user's own shell/editor terminal in the worktree dies on environment delete — accepta
Proposed fix: Two daemon-side layers, no protocol bump: (1) spawn provider CLIs / setup scripts / command terminals as POSIX process-group leaders (detached:true) and signal the group on shutdown, with escalation keyed on 'any group member alive' — but SIGTERM the leader first so the bridge's graceful shutdown still drives the CLI down, group-signal only at the SIGKILL escalation; (2) before workspace.destroy() for a managed workspace, list processes whose cwd is at/under the workspace (Linux /proc/*/cwd, macOS lsof -d cwd), SIGTERM, short grace, rescan, SIGKILL, and log the reaped pids; optionally add a on…
Caveats: The '12h-old claude process' from Deleting a worktree environment leaves its processes running with a cwd that no longer exists #1769 was not reproduced: in my idle and mid-turn runs the claude-code bridge handled SIGTERM gracefully and took claude with it; leaking the CLI itself needs the 5s SIGKILL fallback or a daemon restart before destroy (both real code paths, not provoked live). All reproduction is on Linux; macOS uses the same daemon code path but its lsof-based sweep in the PR was…
The report has copy-paste repro steps, screenshots where the bug is visual, code permalinks at 16ceb3a54, and repro artifacts. It was independently re-run by a second agent (see its Verification section).
Activity
SawyerHood commentedon Aug 18, 2026
Evidence from #1769 (closed as duplicate): on bb 0.38.0 / macOS 26 one machine had 40 destroyed environments still holding 190 live processes and 1.75 GB RSS, swap at 94%, load ~20 on 10 cores. Every process-holding environment was a deleted one; none of the 8 live environments had orphans. A
claudeprovider process was alive 12h46m after its environment was destroyed. Also related: #1660, #1604, #1363.SawyerHood commentedon Aug 18, 2026
Reproduction & root-cause report: https://get-bb.github.io/reports/issues/1647.html
git worktree remove --force, so anything those children detached (nohup dev servers, background jobs, MCP servers after a force-kill, or processes from a pre-restart daemon) survives with a deleted cwd and is never reaped.setsid sleeprooted in the worktree, pid 1641293 reaped), i.e. a user's own shell/editor terminal in the worktree dies on environment delete — acceptaThe report has copy-paste repro steps, screenshots where the bug is visual, code permalinks at
16ceb3a54, and repro artifacts. It was independently re-run by a second agent (see its Verification section).Kill processes left in a destroyed worktree environment
Kill processes left in a destroyed worktree environment (#1696)