Skip to content

Process termination #49335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 16, 2025
Merged

Process termination #49335

merged 5 commits into from
Jun 16, 2025

Conversation

tmat
Copy link
Member

@tmat tmat commented Jun 11, 2025

Simplify process termination. Unify two code paths that were used to gracefully terminate process to a single one.
Converts ProcessRunner to an object that stores cancellation token that is triggered by Ctrl+C. Then use it in ProcessRunner methods to detect whether the process termination was initiated via Ctrl+C or otherwise.

@tmat tmat force-pushed the ProcessTermination branch from 93d54fd to 16d7e13 Compare June 16, 2025 04:35
@tmat
Copy link
Member Author

tmat commented Jun 16, 2025

@DustinCampbell @phil-allen-msft ptal

@tmat tmat marked this pull request as ready for review June 16, 2025 04:35
@Copilot Copilot AI review requested due to automatic review settings June 16, 2025 04:35
@tmat tmat requested review from arunchndr and a team as code owners June 16, 2025 04:35
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR simplifies process termination by unifying code paths and centralizing the handling of process cancellation via a dedicated ProcessRunner instance. Key changes include:

  • Replacing static process termination calls with an instance-based ProcessRunner that accepts a cancellation token.
  • Updating various methods across tests and production code to incorporate caller information for logging and to align with the new ProcessRunner pattern.
  • Adjusting reporter messages and test expectations to match the unified termination behavior.

Reviewed Changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/dotnet-watch.Tests/Watch/Utilities/WatchableApp.cs Updated types and assertions to use DebugTestOutputLogger and new caller info.
test/dotnet-watch.Tests/Utilities/MockFileSetFactory.cs Revised instantiation including a redundant ternary expression for environment options and addition of ProcessRunner argument.
test/dotnet-watch.Tests/MsBuildFileSetFactoryTest.cs, NoRestoreTests.cs, MSBuildEvaluationFilterTest.cs, ... Updated tests to consistently instantiate and pass ProcessRunner.
src/BuiltInTools/dotnet-watch/Program.cs, DotNetWatcher.cs, DotNetWatchContext.cs, ... Revised process creation and termination calls to use ProcessRunner and updated reporter messaging.
src/BuiltInTools/dotnet-watch/Internal/ProcessRunner.cs Refactored process termination logic to be instance-based and added asynchronous helper methods.
src/BuiltInTools/dotnet-watch/HotReload* Updated hot-reload related components to work with the new process termination logic.

@tmat tmat requested a review from a team as a code owner June 16, 2025 17:36
@tmat tmat force-pushed the ProcessTermination branch from 2307e90 to 16d7e13 Compare June 16, 2025 18:37
@marcpopMSFT
Copy link
Member

only failure was from the known container issue that dnceng is working on. Requested to merge on red

@marcpopMSFT marcpopMSFT merged commit b46e1c0 into dotnet:main Jun 16, 2025
5 of 30 checks passed
@tmat tmat deleted the ProcessTermination branch June 16, 2025 22:42
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.

3 participants