-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Unix process termination #49374
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
Unix process termination #49374
Conversation
Thanks for your PR, @@tmat. |
d58f47e
to
b5bf3f5
Compare
f54fe57
to
9bb9b15
Compare
6d642dd
to
787848e
Compare
@DustinCampbell ptal |
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 enhances Unix process termination and reliability for dotnet watch
by multi-targeting the DeltaApplier, registering a SIGTERM handler, and improving WaitForExitAsync
to avoid hangs. It also updates tests to be cross-platform and configures polling for file-watcher tests.
- Add SIGTERM registration in the startup hook for graceful shutdown on Unix (net10+).
- Refactor
ProcessRunner.WaitForExitAsync
with a polling loop to address hangs on Linux. - Enable polling file watcher in tests and remove Windows‐only
[PlatformSpecificFact]
attributes.
Reviewed Changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
test/.../WatchableApp.cs | Add comment and enable polling file watcher in tests |
test/.../ProgramTests.cs (and many) | Replace [PlatformSpecificFact/Theory] with [Fact/Theory] for cross-platform tests |
test/.../TestOptions.cs | Use 1s timeout on Unix and 0s on Windows for process cleanup |
test/TestAssets/.../AppWithDeps/Program.cs | Increase loop delay from 10ms to 1000ms in test asset |
src/.../dotnet-watch.csproj | Multi-target Microsoft.Extensions.DotNetDeltaApplier for net10.0 and netstandard2.1 |
src/.../Internal/ProcessRunner.cs | Refactor WaitForExitAsync to poll HasExited and log verbose messages |
src/.../HotReload/StartupHook.cs | Add RegisterPosixSignalHandlers to handle SIGTERM and exit process |
Comments suppressed due to low confidence (1)
src/BuiltInTools/DotNetDeltaApplier/StartupHook.cs:86
- No tests cover the new SIGTERM handler. Consider adding integration or unit tests to verify that the handler correctly triggers
Environment.Exit(0)
on Unix when SIGTERM is received.
private static void RegisterPosixSignalHandlers()
test/TestAssets/TestProjects/WatchAppWithProjectDeps/AppWithDeps/Program.cs
Outdated
Show resolved
Hide resolved
787848e
to
7fb58e9
Compare
7fb58e9
to
e06e2ac
Compare
e06e2ac
to
f0e9c2a
Compare
Multi-targets DotNetDeltaApplier in order to use Posix signal registration API. Register
SIGTERM
signal and exit the process. This is only needed for net10+ due to dotnet/docs#46226.Since our startup hook is the first to execute in the app process, the registered handler will be the last to execute. See dotnet/runtime#116557.
The change also had to update
WaitForExitAsync
to avoid hangs on Unix. It's unclear why. The implementation of this API is generally unreliable, see dotnet/runtime#109434.Blazor and WebApp tests still disabled. Needs more investigation.