-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
ConsoleLifetime clobbers any exit code set by calling Environment.Exit() #42224
Comments
It looks like we're setting the value to 0 by default and should maybe be checking for 143 instead runtime/src/libraries/Microsoft.Extensions.Hosting/src/Internal/ConsoleLifetime.cs Line 89 in 6faf435
|
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @eerhardt, @maryamariyan |
Don't listen to ProcessExit on net6.0+ in Hosting anymore. This allows for Environment.Exit to not hang the app. Don't clobber ExitCode during ProcessExit now that SIGTERM is handled separately. For non-net6.0 targets, only wait for the shutdown timeout, so the process doesn't hang forever. Fix dotnet#55417 Fix dotnet#44086 Fix dotnet#50397 Fix dotnet#42224 Fix dotnet#35990
* Add NetCoreAppCurrent target to Microsoft.Extensions.Hosting * Handle SIGTERM in Hosting and handle just like SIGINT (CTRL+C) Don't listen to ProcessExit on net6.0+ in Hosting anymore. This allows for Environment.Exit to not hang the app. Don't clobber ExitCode during ProcessExit now that SIGTERM is handled separately. For non-net6.0 targets, only wait for the shutdown timeout, so the process doesn't hang forever. Fix #55417 Fix #44086 Fix #50397 Fix #42224 Fix #35990 * Remove _shutdownBlock on netcoreappcurrent, as this is no longer waited on * Change Console.CancelKeyPress to use PosixSignalRegistration SIGINT and SIGQUIT * Use a no-op lifetime on mobile platforms * Add docs for shutdown
This is fixed on .NET 6 only |
Describe the bug
ConsoleLifetime clobbers any exit code set by calling Environment.Exit()
To Reproduce
Program.cs:
ConsoleLifetimeTest.csproj:
Steps to reproduce the behavior:
Expected behavior
Process to exit with code 123
Additional context
The change in this PR seems to be responsible, explicitly setting Environment.ExitCode to 0: dotnet/aspnetcore#6526
The text was updated successfully, but these errors were encountered: