bug(desktop): orphaned opencode-cli processes on Linux after app exit #8429

Open
opened 2026-02-16 18:09:57 -05:00 by yindo · 1 comment
Owner

Originally created by @IsraelAraujo70 on GitHub (Feb 3, 2026).

Originally assigned to: @adamdotdevin on GitHub.

Problem

On Linux, the desktop app leaves opencode-cli sidecar processes running after the UI exits or crashes. This accumulates orphaned processes and memory usage. Windows has job objects; Linux had no equivalent cleanup.

Repro

  1. Launch the desktop app.
  2. Open a project / start the local sidecar server.
  3. Close the app or crash/kill the UI.
  4. ps still shows opencode / opencode-cli processes running.

Fix (already implemented in branch)

  • Add Linux process group management with PR_SET_PDEATHSIG and setsid for child cleanup.
  • Track PIDs and kill process groups on exit.
  • Spawn sidecar on Linux with pre_exec calling configure_child_process.
  • Add libc dependency for prctl/setsid.

Commit: 4bd93a5a5 (fix(desktop): ensure child processes are killed on Linux when app exits).

Verification

Closing the app now sends SIGTERM to the child and its process group; no orphan processes remain.

Originally created by @IsraelAraujo70 on GitHub (Feb 3, 2026). Originally assigned to: @adamdotdevin on GitHub. ## Problem On Linux, the desktop app leaves opencode-cli sidecar processes running after the UI exits or crashes. This accumulates orphaned processes and memory usage. Windows has job objects; Linux had no equivalent cleanup. ## Repro 1) Launch the desktop app. 2) Open a project / start the local sidecar server. 3) Close the app or crash/kill the UI. 4) `ps` still shows `opencode` / `opencode-cli` processes running. ## Fix (already implemented in branch) - Add Linux process group management with `PR_SET_PDEATHSIG` and `setsid` for child cleanup. - Track PIDs and kill process groups on exit. - Spawn sidecar on Linux with `pre_exec` calling `configure_child_process`. - Add `libc` dependency for `prctl/setsid`. Commit: `4bd93a5a5` (fix(desktop): ensure child processes are killed on Linux when app exits). ## Verification Closing the app now sends SIGTERM to the child and its process group; no orphan processes remain.
yindo added the web label 2026-02-16 18:09:57 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 3, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #11527: OpenCode leaves an orphaned process when it itself is killed
  • #10563: Memory Leak: Orphaned processes when terminal closes without explicit exit
  • #11225: [BUG]: opencode attach processes not terminated when tmux pane is killed
  • #6633: [Bug] MCP processes not terminated after session ends
  • #7261: v1.1.6 still has memory bloat - heap not released + MCP orphan processes
  • #9153: Memory leak: MCP OAuth transports not closed on retry or cancellation

These issues all describe similar orphaned process problems. The Linux-specific solution you've implemented (using PR_SET_PDEATHSIG and setsid) may help resolve multiple related issues beyond just the desktop app.

Feel free to ignore if this specific Linux desktop app scenario is distinct from these other cases.

@github-actions[bot] commented on GitHub (Feb 3, 2026): This issue might be a duplicate of existing issues. Please check: - #11527: OpenCode leaves an orphaned process when it itself is killed - #10563: Memory Leak: Orphaned processes when terminal closes without explicit exit - #11225: [BUG]: opencode attach processes not terminated when tmux pane is killed - #6633: [Bug] MCP processes not terminated after session ends - #7261: v1.1.6 still has memory bloat - heap not released + MCP orphan processes - #9153: Memory leak: MCP OAuth transports not closed on retry or cancellation These issues all describe similar orphaned process problems. The Linux-specific solution you've implemented (using PR_SET_PDEATHSIG and setsid) may help resolve multiple related issues beyond just the desktop app. Feel free to ignore if this specific Linux desktop app scenario is distinct from these other cases.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8429