This repository was archived by the owner on Apr 20, 2023. It is now read-only.
Repository navigation
Improve Ctrl-C experience for dotnet run. - #10544
Merged
Merged
Conversation
Author
|
Note: there is not a Windows test for this for the same reason corefx doesn't test |
livarcocc
approved these changes
Jan 7, 2019
This commit improves the handling of the SIGINT signal from `dotnet run`. The current behavior of `dotnet run` is to use the default handler for the SIGINT signal. This results in the termination of the `dotnet run` process with an exit status of 130 on POSIX systems and 0xC000013A on Windows. This prevents a child process to gracefully handle SIGINT by returning a zero exit code or from ignoring the signal entirely and letting the process appear to continue to run. Additionally, the child process of `dotnet run` may still be writing to stdout during the handling of SIGINT. Because `dotnet run` may terminate before the child process does, a waiting parent of `dotnet run`, such as a shell, may proceed to print out a new prompt to the user while the child continues to write to stdout. This results in inconsistent and interleaved output in a terminal and can be a source of confusion to users. This commit changes `dotnet` to always ignore SIGINT when spawning a child process. This allows the child process to handle the signal and decide what to do with it. As a result, the UX from when the user program is run directly and run via `dotnet run` is the same regarding SIGINT. Fixes #812.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit improves the handling of the SIGINT signal from
dotnet run.The current behavior of
dotnet runis to use the default handler for theSIGINT signal. This results in the termination of the
dotnet runprocesswith an exit status of 130 on POSIX systems and 0xC000013A on Windows. This
prevents a child process to gracefully handle SIGINT by returning a zero exit
code or from ignoring the signal entirely and letting the process appear to
continue to run.
Additionally, the child process of
dotnet runmay still be writing to stdoutduring the handling of SIGINT. Because
dotnet runmay terminate before thechild process does, a waiting parent of
dotnet run, such as a shell, mayproceed to print out a new prompt to the user while the child continues to
write to stdout. This results in inconsistent and interleaved output in a
terminal and can be a source of confusion to users.
This commit changes
dotnetto always ignore SIGINT when spawning a childprocess. This allows the child process to handle the signal and decide what to
do with it. As a result, the UX from when the user program is run directly or
via
dotnet runis the same regarding SIGINT.Fixes #812.