-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Send Ctrl+C to launched process before killing it on Windows #49847
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
base: main
Are you sure you want to change the base?
Conversation
Thanks for your PR, @@tmat. |
1fe04bf
to
4d7541d
Compare
There was a problem hiding this 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 implements graceful termination of dotnet-watch processes on Windows by enabling Ctrl+C signal handling. The primary goal is to allow Windows processes launched by dotnet-watch to receive and handle Ctrl+C events properly before being forcefully terminated.
Key changes:
- Added Windows-specific Ctrl+C event handling using Windows API calls
- Modified process creation to use CREATE_NEW_PROCESS_GROUP flag for user applications on Windows
- Updated timeout values to allow graceful shutdown instead of immediate termination
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/BuiltInTools/dotnet-watch/Utilities/ProcessUtilities.cs |
New utility class with Windows API interop for Ctrl+C handling and signal management |
src/BuiltInTools/dotnet-watch/Process/ProcessRunner.cs |
Modified process termination logic to support graceful shutdown with Ctrl+C on Windows |
src/BuiltInTools/dotnet-watch/Process/ProcessSpec.cs |
Added IsUserApplication property to distinguish between user apps and helper processes |
test/dotnet-watch.Tests/TestUtilities/WatchableApp.cs |
Updated test utilities to enable Windows Ctrl+C handling and increased timeout values |
test/dotnet-watch.Tests/HotReload/ApplyDeltaTests.cs |
Added Windows-specific test for graceful termination and updated existing tests |
src/BuiltInTools/DotNetDeltaApplier/StartupHook.cs |
Extended signal handling to include Windows Ctrl+C support |
Comments suppressed due to low confidence (2)
src/BuiltInTools/dotnet-watch/Utilities/ProcessUtilities.cs:81
- The .NET version 'NET10_0_OR_GREATER' does not exist. Consider using a valid .NET version like 'NET8_0_OR_GREATER' or 'NET9_0_OR_GREATER'.
#if NET10_0_OR_GREATER
src/BuiltInTools/DotNetDeltaApplier/StartupHook.cs:91
- The .NET version 'NET10_0_OR_GREATER' does not exist. Consider using a valid .NET version like 'NET8_0_OR_GREATER' or 'NET9_0_OR_GREATER'.
#if NET10_0_OR_GREATER
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Use API added by dotnet/runtime#44944 to enable sending Ctrl+C to child processes on Windows.
Only uses this flag for application processes launched by dotnet-watch (not for auxiliary processes like
dotnet build
).