Skip to content

fix(cli): detach Windows daemons from caller pipes and jobs - #282

Open
iuyo5678 wants to merge 1 commit into
mainfrom
iuyo5678/fix-windows-daemon-detach
Open

iuyo5678 wants to merge 1 commit into
mainfrom
iuyo5678/fix-windows-daemon-detach

Conversation

@iuyo5678

Copy link
Copy Markdown
Collaborator

Windows background startup can leave captured stdout/stderr open after the launcher exits, and the daemon can die when the host cleans up its Job Object. This change separates pipe ownership from daemon lifetime and refuses background startup when the host cannot release the daemon.

  • Use an explicit inherited-handle list containing only dedicated stdio handles; share this native process helper with the Windows updater.
  • Create the daemon suspended with Job breakaway requested, verify it belongs to no Job (including outer nested Jobs), and only then resume it. Restricted hosts receive actionable persistent-host setup instructions; existing reachable daemons remain reusable.
  • Share direct startup and one readiness deadline between explicit and automatic startup. Retain child ownership until readiness, clean up failed or losing concurrent starters, and reap Unix children after handoff.
  • Add native Windows pipe EOF, Job lifetime, nested Job, concurrency, failure cleanup, Unicode path and auto-start regressions to CI. Document foreground ownership and persistent-host setup.

Validation completed before committing:

  • Windows: five consecutive startup regression runs, including separate process-exit and stdout/stderr EOF assertions, Job close/termination, restrictive and nested Jobs, six concurrent starters, failed startup cleanup and daemon reuse.
  • Windows: two consecutive updater regression runs; existing IPC, audit, discovery lock, startup, probe, CLI, browser interaction and parent-cancellation tests passed.
  • Windows: formatting, all-target check and all-target Clippy passed; Clippy still reports existing unrelated Windows warnings.
  • Linux (WSL): cargo fmt --all -- --check, cargo clippy --workspace --all-targets --locked -- -D warnings, and cargo test --workspace --locked all passed, including the new Unix child-reaping test.

Local coverage limit: the default-port automatic-start success case was skipped because port 52800 belongs to an existing developer daemon. That process was left running. The new Windows CI step requires the port to be free and executes this case; random-port explicit startup and automatic-start refusal paths were exercised locally.

Addresses the Windows pipe and Job lifetime failures in #268. Query commands retain their existing automatic-start defaults; BSK_AUTO_START=0 remains the opt-out for probes. Changing query defaults is outside this change.

Use an explicit standard-handle inheritance list for daemon startup and the
Windows update helper. Require and verify breakaway before resuming a
background daemon, with an actionable error for restrictive host Jobs.

Share direct startup and its readiness deadline across explicit and
automatic entry points, retain child ownership through startup, and reap
Unix children after handoff.

Add native Windows EOF, Job lifetime, concurrency and failure regressions
to CI, and document persistent host setup.

Refs #268
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant