orca/docs
Jinwoo Hong a638215729
fix(pty): release ptmx fd on natural exit + defuse SIGHUP-to-recycled-pid (#1327)
* fix(pty): release ptmx fd on natural exit + defuse SIGHUP-to-recycled-pid

Daemons accumulated ptmx fds over time because node-pty's UnixTerminal
only releases the master fd when destroy() runs. On the natural-exit
path (the common case — user closes a tab, shell runs `exit`) nothing
ever calls destroy(), so the fd leaks until GC. On macOS this
eventually hits kern.tty.ptmx_max=511 and all new terminals fail to
spawn.

Fix: release the fd synchronously on every teardown path (natural
exit, explicit kill, stale SSH spawn, daemon shutdown) and close the
concurrent SIGHUP-to-recycled-pid hazard inside node-pty's
UnixTerminal.destroy().

- src/main/daemon/pty-subprocess.ts: synchronous POSIX proc.kill
  neutralization inside proc.onExit; dead guards on forceKill/signal
  so they never target a reaped-and-possibly-recycled pid
- src/main/daemon/session.ts: new disposeSubprocess() for already-
  exited sessions (fd release only, no SIGKILL) — avoids sending
  SIGKILL to a recycled pid during daemon shutdown
- src/main/daemon/terminal-host.ts: dispose loop routes on isAlive —
  live sessions get forceKillAndDisposeSubprocess (SIGKILL + fd
  release), exited sessions get disposeSubprocess (fd release only)
- src/main/providers/local-pty-provider.ts: same POSIX kill
  neutralization at top of onExit for the legacy local path
- src/relay/pty-handler.ts: same neutralization in wireAndStore;
  disposed flag guards all public entry points; dispose() uses
  SIGKILL (not SIGTERM) before destroy since the relay is exiting;
  killTimer fallback + immediate-shutdown + stale-spawn cleanup all
  call disposeManagedPty + ptys.delete so wedged children (D-state,
  bad NFS) can't leak map entries against the 50-PTY cap

Windows is exempt everywhere — WindowsTerminal.destroy IS a kill()
call internally (closes the ConPTY agent), so neutralizing would
turn destroy into a no-op and leak the agent.

See docs/fix-pty-fd-leak.md for the full design.

Co-authored-by: Orca <help@stably.ai>

* fix(pty): patch node-pty native off-by-one leaking /dev/ptmx per spawn

node-pty 1.1.0's pty_posix_spawn on macOS walks low_fds[0..2] in an
allocation loop that breaks at the first fd >= STDERR_FILENO, then
cleans up via `for (; count > 0; count--) close(low_fds[count])`. In
the typical case (break at count=0) the cleanup body never runs and
low_fds[0] — a /dev/ptmx handle — leaks per spawn. Fixed upstream in
microsoft/node-pty af053f2 (PR #882), not in any 1.1.0 release.

Backport the 3-line cleanup-loop fix as a pnpm patch. E2E validated
against a dev daemon: 200 spawn/kill cycles kept the daemon's ptmx
fd count flat at baseline; prior runs reproduced linear 1-per-spawn
growth. Also documents the native root cause as a status addendum in
docs/fix-pty-fd-leak.md — the JS-side destroy() discipline previously
landed is still load-bearing for the SIGHUP-to-recycled-pid hazard and
for synchronous fd release on daemon shutdown.

Co-authored-by: Orca <help@stably.ai>

* fix(pty): capture stable kill spy ref in pty.test.ts

destroyPtyProcess reassigns proc.kill = () => {} on POSIX to defuse
the SIGHUP-to-recycled-pid hazard (see docs/fix-pty-fd-leak.md). After
that reassignment, proc.kill.mock is undefined and the assertions
crashed in CI. Capture a stable reference to the vi.fn() before it
gets reassigned.

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Orca <help@stably.ai>
2026-05-02 23:12:14 -07:00
..
assets docs(readme): add Annotate AI Diff feature, SSH support, and Spanish translation (#1080) 2026-04-25 00:01:53 -07:00
design refactor: rename pet → sidekick across codebase (#1334) 2026-05-01 18:40:52 -07:00
superpowers feat: add .mmd/.mermaid file viewer with rendered diagram toggle (#597) 2026-04-14 19:26:55 -07:00
README.es.md docs: fix README header alignment (#1320) 2026-05-01 12:46:56 -07:00
README.ja.md docs: fix README header alignment (#1320) 2026-05-01 12:46:56 -07:00
README.md Add Orca runtime CLI and bundled install support (#273) 2026-04-03 16:50:28 -07:00
README.zh-CN.md docs: fix README header alignment (#1320) 2026-05-01 12:46:56 -07:00
back-button-tasks-page.md feat(nav): back/forward traverses Tasks page visits (#1207) 2026-04-27 23:49:34 -07:00
cmd-j-scoped-jump-palette-plan.md feat: add browser tab search to Cmd+J jump palette (#675) 2026-04-15 12:54:56 -07:00
codex-account-switching-design.md feat(codex-accounts): shared runtime home for account switching (#768) 2026-04-17 21:51:06 -07:00
create-from-start-field.md fix: address review findings (#1078) 2026-04-24 21:58:21 -07:00
design-379.md feat: add searchable repo picker to new worktree dialog (#559) 2026-04-12 18:50:24 -07:00
design-preserve-scroll-position.md refactor to clean up the codebase (#412) 2026-04-08 22:49:16 -07:00
drag-drop-files-ssh.md feat(file-explorer): support drag-and-drop file import over SSH (#1279) 2026-04-30 01:28:43 -07:00
file-explorer-external-drop.md feat: allow dropping external files into the file explorer (#618) 2026-04-13 22:04:49 -07:00
fix-codex-token-refresh-loss.md fix: prevent 401 errors from CLI-refreshed tokens being clobbered (#1286) 2026-04-30 22:24:10 -07:00
fix-missing-single-instance-lock.md fix(runtime): add single-instance lock + owned-metadata clear (#1312) (#1326) 2026-05-02 23:05:14 -07:00
fix-pty-fd-leak.md fix(pty): release ptmx fd on natural exit + defuse SIGHUP-to-recycled-pid (#1327) 2026-05-02 23:12:14 -07:00
focus-follows-mouse-design.md feat: focus-follows-mouse setting for terminal panes (#389) 2026-04-09 17:02:01 -07:00
focus-follows-mouse-plan.md feat: focus-follows-mouse setting for terminal panes (#389) 2026-04-09 17:02:01 -07:00
homebrew-cask.md feat(release): publish Orca as a Homebrew cask (#1304) 2026-05-01 00:33:21 -07:00
performance-audit.md perf: systematic performance optimizations (#623) 2026-04-14 00:28:56 -07:00
performance-implementation-plan.md perf: systematic performance optimizations (#623) 2026-04-14 00:28:56 -07:00
preload-typecheck-hole.md fix(preload): collapse index.d.ts into type-checked api-types.ts (#1197) 2026-04-27 21:46:17 -07:00
quickly-jump-to-worktree.md fix: address review findings (#1078) 2026-04-24 21:58:21 -07:00
remote-folder-picker-redesign.md improve remote folder picker UI (#1240) 2026-04-28 18:52:31 -07:00
split-groups-rollout-pr1.md refactor: add split group model foundations (#644) 2026-04-14 14:39:01 -07:00
split-groups-rollout-pr2.md fix: harden terminal pane lifecycle for split groups (#641) 2026-04-14 16:23:01 -07:00
split-groups-rollout-pr3.md fix: restore worktrees through tab group ownership (#645) 2026-04-14 17:01:58 -07:00
split-groups-rollout-pr4.md feat: add split group UI with tab-bar context menus and resize handles (#646) 2026-04-14 19:01:11 -07:00
split-groups-rollout-pr5.md refactor: gate split group surface ownership in Terminal.tsx (#642) 2026-04-14 20:19:11 -07:00
split-groups-rollout-pr6.md feat: enable split groups renderer path (#669) 2026-04-15 13:12:54 -07:00
ssh-split-pane-inherit-cwd.md fix(terminal): inherit source pane cwd on split (Cmd+D) (#1243) 2026-04-29 15:54:07 -07:00
tab-group-model-follow-up.md feat: add split group UI with tab-bar context menus and resize handles (#646) 2026-04-14 19:01:11 -07:00
term-shortcut-fix.md fix: audit terminal shortcut interception (#519) 2026-04-11 23:24:04 -07:00
terminal-drop-ssh.md fix: handle unhydrated store in file-explorer→terminal drop (#1296) 2026-04-30 20:39:04 -07:00
terminal-extended-keys.md fix(terminal): advertise kitty keyboard protocol for Shift+Enter (#1247) 2026-04-28 23:56:29 -07:00

README.md

Orca CLI Docs

Keep this folder focused on the durable references for Orca's public CLI and runtime model.

Keep These Docs

  • orca-cli-focused-v1-status.md
    • What is actually implemented and intentionally in scope now.
  • orca-cli-v1-spec.md
    • The public CLI contract, selector grammar, JSON envelope, and command semantics.
  • orca-runtime-layer-design.md
    • Why the runtime layer exists and which boundaries it owns.
  • orca-cli-bundled-distribution.md
    • How the bundled desktop-app distribution and PATH registration model works.

Why The Folder Is Small

Earlier design and implementation work produced several planning and evaluation docs. Those were useful while the feature was taking shape, but they were intentionally removed once the implementation converged so future readers are not forced to choose between multiple overlapping sources of truth.