Skip to content

fix(windows): let output readers own pipe cleanup - #111

Draft
Haloukaidi wants to merge 1 commit into
lbx154:mainfrom
Haloukaidi:fix/windows-reader-pipe-ownership
Draft

fix(windows): let output readers own pipe cleanup#111
Haloukaidi wants to merge 1 commit into
lbx154:mainfrom
Haloukaidi:fix/windows-reader-pipe-ownership

Conversation

@Haloukaidi

Copy link
Copy Markdown

On Windows, closing a pipe descriptor from the main thread while another thread is blocked reading it can itself block. The reader join timeout is reached only after that close returns, so it does not bound cleanup when an independent child still holds the write end.

Give each output reader ownership of closing its stream. The caller stops retaining output and waits briefly; readers continue draining/discarding late output until the independent writer closes. Surface active read failures, and clean up the provider and any partially started readers when callbacks or thread startup fail.

Validation on Windows / Python 3.13:

  • 41 tests passed across output lifecycle, stream callbacks, and execution-host failures.
  • A real independent child retains stdout/stderr after the provider exits, then writes large late output successfully without BrokenPipe. The invocation returns before that child releases its pipes.
  • Additional cases cover repeated calls, observer exceptions, read errors, and failure to start the second reader.
  • Ruff and git diff --check passed.

Draft for lifecycle and cross-platform review. Descendant ownership is discussed separately in #106; this PR does not terminate independently owned work to manufacture EOF.

lbx154 added a commit that referenced this pull request Sep 8, 2026
Suspend providers before assignment; retain handles through cleanup and preserve explicit durable breakaway launchers. Reuse reviewed stdin and reader lifecycle corrections from PRs #110 and #111 to keep stop and watchdog paths reachable. Add native Windows ownership and PowerShell acceptance checks.
lbx154 added a commit that referenced this pull request Sep 8, 2026
Suspend providers before assignment; retain handles through cleanup and preserve explicit durable breakaway launchers. Reuse reviewed stdin and reader lifecycle corrections from PRs #110 and #111 to keep stop and watchdog paths reachable. Add native Windows ownership and PowerShell acceptance checks.
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