Repository navigation
Use Process.StartAndForget for fire-and-forget process launches - #54093
Merged
Merged
Conversation
… process launching Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/530c5ee1-aa5c-4ad3-ba82-fe8274732a35 Co-authored-by: adamsitnik <[email protected]>
adamsitnik
reviewed
Apr 27, 2026
3 tasks
adamsitnik
reviewed
Jun 12, 2026
adamsitnik
left a comment
Member
There was a problem hiding this comment.
@copilot please address my feedback
Co-authored-by: adamsitnik <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates fire-and-forget subprocess launches to use Process.StartAndForget(...) so call sites don’t leak Process handles, and (where applicable) avoid redirected stdio pipes that can deadlock when not drained.
Changes:
- Switch
CleanFileBasedAppArtifactsCommandautomatic cleanup launch fromProcess.StarttoProcess.StartAndForget, removing unused stdio redirection. - Update Razor server launch logic to use
Process.StartAndForgeton non-.NET Framework targets, while retaining a .NET Framework-specific path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/RazorSdk/Tool/ServerProtocol/ServerConnection.cs | Uses Process.StartAndForget for fire-and-forget server startup (with NETFRAMEWORK fallback and redirect guards). |
| src/Cli/dotnet/Commands/Clean/FileBasedAppArtifacts/CleanFileBasedAppArtifactsCommand.cs | Starts automatic cleanup via Process.StartAndForget and removes unused stdio redirection. |
Youssef1313
reviewed
Jun 25, 2026
Youssef1313
approved these changes
Jun 25, 2026
Youssef1313
left a comment
Member
There was a problem hiding this comment.
Overall LGTM
@jjonescz for another look for file-based apps clean.
@davidwengier maybe for the Razor part
jjonescz
approved these changes
Jun 25, 2026
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.
Adopt
Process.StartAndForget(dotnet/runtime#126078) at call sites whereProcess.Startwas used in a fire-and-forget pattern, leaking the returnedProcesshandle.CleanFileBasedAppArtifactsCommand.cs— cleanup subprocess launched with discarded return value. The previous code redirected standard streams but never consumed them, which could lead to deadlocks;StartAndForgetredirects to the null device by default.ServerConnection.cs— Razor server subprocess launched, only.Idread from the handle. Uses#if NETFRAMEWORKguards to retain the originalProcess.Start+ redirect behavior on net472 (whereStartAndForgetis unavailable) while usingStartAndForgeton .NET Core+.