Skip to content

Conversation

tmat
Copy link
Member

@tmat tmat commented Jul 17, 2025

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).

@github-actions github-actions bot added the Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, dotnet-watch label Jul 17, 2025
Copy link
Contributor

Thanks for your PR, @@tmat.
To learn about the PR process and branching schedule of this repo, please take a look at the SDK PR Guide.

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 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

@tmat tmat marked this pull request as draft July 29, 2025 00:26
@tmat
Copy link
Member Author

tmat commented Jul 29, 2025

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@tmat tmat marked this pull request as ready for review July 29, 2025 20:54
@tmat tmat enabled auto-merge (squash) July 30, 2025 22:32
@tmat tmat merged commit fc80484 into dotnet:main Jul 30, 2025
27 checks passed
@tmat tmat deleted the WinCtrlC branch July 30, 2025 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, dotnet-watch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants