This repository has been archived by the owner on Apr 20, 2023. It is now read-only.
Improve Ctrl-C experience for dotnet run
.
#10544
Merged
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 run
is to use the default handler for theSIGINT signal. This results in the termination of the
dotnet run
processwith 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 stdoutduring the handling of SIGINT. Because
dotnet run
may 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
dotnet
to 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 run
is the same regarding SIGINT.Fixes #812.