/ curl Public
tool_doswin: Restore original console settings on CTRL signal #6226
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.
Move Windows terminal init code from tool_main to tool_doswin.
Restore the original console settings on CTRL+C and CTRL+BREAK.
Background: On Windows the curl tool changes the console settings to
enable virtual terminal processing (eg color output) if supported
(ie Win 10). The original settings are restored on exit but prior to
this change were not restored in the case of the CTRL signals.
@bitcrazed can you take a look at this please. It was my understanding from #3008 that if VT was set on the console then it needed to be restored on exit. Currently that doesn't happen on CTRL+C / CTRL+BREAK signals, so I made some changes in this PR to address that.
However.. after that I did some empirical testing in Windows 10 20H2 that makes me wonder if restoring the console's original vt setting is necessary in any case, since the system appears to do that already. Take for example the C program below that was run twice from the same command prompt console and turns on VT without shutting it off again: