Repository navigation
Keep detached daemon from holding the caller's stdio pipes. Closes #2080 - #2094
Open
waldekmastykarz wants to merge 2 commits into
Open
waldekmastykarz wants to merge 2 commits into
waldekmastykarz wants to merge 2 commits into
Conversation
On Windows, Process.Start uses CreateProcess with bInheritHandles=TRUE, so the daemon inherited the caller's inheritable stdout/stderr handles. Callers that read devproxy --detach output to EOF (| Out-String, $(...), subprocess pipes) then hung until the daemon exited. Clear the inherit flag on the parent's std handles before spawning, redirect the daemon's stdin as well, and add an integration test that captures --detach output and requires EOF. Closes dotnet#2080 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The EOF-timeout assertion can fail before the daemon PID is captured, causing cleanup to leave the detached daemon running after the failed test.
1 open issue
What changed in this PR
Fixes detached startup hanging callers that capture output by preventing the daemon from retaining the caller’s standard I/O handles.
Changes:
- Disables inheritance of the launcher’s standard handles on Windows.
- Redirects and closes daemon stdin while preserving stdout/stderr capture for startup errors.
- Adds text and JSON regression tests requiring captured output to reach EOF while the daemon remains running.
| File | Description |
|---|---|
| DevProxy/Proxy/StandardHandleInheritance.cs | Adds Windows-only standard-handle inheritance control. |
| DevProxy/Program.cs | Applies inheritance control and redirects daemon stdin. |
| DevProxy.Integration.Tests/ProcessSmokeTests.cs | Tests captured-output EOF and continued daemon operation. |
Review effort: Balanced
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Reported checks cover only macOS tests and Linux builds, leaving Windows captured-output EOF—including merged stdout/stderr while the daemon remains alive—and early-startup error reporting unverified.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

devproxy --detachhung callers that capture its output (devproxy --detach 2>&1 | Out-String,$(devproxy --detach),subprocess/execSyncwith pipes).Cause
On Windows,
Process.StartcallsCreateProcesswithbInheritHandles = TRUE, so the daemon inherits every inheritable handle of thedevproxy --detachparent, not just the redirected pipes assigned as its stdio. The stdout/stderr handles the caller passes in are inheritable, so the long-running daemon kept the caller's pipe open and the caller never saw EOF.On Unix,
fork/execreplaces fds 0–2 with the redirected pipes, so the caller's pipe isn't held (verified on macOS:out=$(devproxy --detach ... | cat)returns in ~1s).Changes
HANDLE_FLAG_INHERITon the parent's std handles (StandardHandleInheritance, Windows-only, no-op elsewhere). The parent keeps using them; only inheritance is affected.--_internal-daemon).Detach_WithCapturedOutput_ParentOutputReachesEofWhileDaemonKeepsRunning(text + json): runsdevproxy --detachwith captured pipes, requires EOF within 15s of the parent exiting, and checks the daemon is still running.Testing
ProcessSmokeTestspass on macOS (11/11).Closes #2080