Repository navigation
bootloader: Windows: implement handling of console ctrl signals - #6935
Merged
Merged
Conversation
Remove the ingoring of SIGABRT, SIGINT, SIGTERM, and SIGBREAK in Windows codepath for the parent process of the onefile mode, and replace it with handling of Windows-specific console control signals. Ignoring SIGABRT has little value, as it is usually generated by abnormal conditions within the process (e.g., code calling `abort()` due to failing validation); so ignoring it is akin to ignoring bugs in the bootloader code. SIGTERM is, as per MSDN, never generated on Windows (although it could be raised programmatically?). And ignoring SIGINT and SIGBREAK prevents us from properly processing the corresponding console control signals. For onefile parent process, install the console ctrl signal handler using the `SetConsoleCtrlHandler` win32 API function. The installed handler suppresses CTRL_C_EVENT and CTRL_BREAK_EVENT signals, which should be equivalent of the old SIGINT and SIGBREAK suppression. But it also delays the parent process' termination in cases of CTRL_CLOSE_EVENT (user closing the parent console window), CTRL_LOGOFF_EVENT (user logging off), and CTRL_SHUTDOWN_EVENT (system shutting down), in an attempt to buy time for the child process to exit and for the main thread of the parent process to perform the clean-up of the temporary directory.
Document the newly added handling of Windows console control signals and the shutdown behavior when using Ctrl+C/Ctrl+Break, closing the console, or trying to shut down the frozen application from the Task Manager.
rokm
force-pushed
the
win-console-ctrl-handler
branch
from
July 10, 2022 16:46
d63d9c1 to
ef47a6b
Compare
rokm
marked this pull request as ready for review
July 10, 2022 16:49
bwoodsend
approved these changes
Jul 10, 2022
Legorooj
approved these changes
Jul 10, 2022
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.
Remove the ingoring of
SIGABRT,SIGINT,SIGTERM, andSIGBREAKin Windows codepath for the parent process of the onefile mode, and replace it with handling of Windows-specific console control signals. IgnoringSIGABRThas little value, as it is usually generated by abnormal conditions within the process (e.g., code callingabort()due to failing validation); so ignoring it isakin to ignoring bugs in the bootloader code.
SIGTERMis, as per MSDN, never generated on Windows (although it could be raised programmatically?). And ignoring SIGINT and SIGBREAK prevents us from properly processing the corresponding console control signals.For onefile parent process, install the console ctrl signal handler using the
SetConsoleCtrlHandlerwin32 API function. The installed handler suppressesCTRL_C_EVENTandCTRL_BREAK_EVENTsignals, which should be equivalent of the oldSIGINTandSIGBREAKsuppression. But it also delays the parent process' termination in cases ofCTRL_CLOSE_EVENT(user closing the parent console window),CTRL_LOGOFF_EVENT(user logging off), andCTRL_SHUTDOWN_EVENT(system shutting down), in an attempt to buy time for the child process to exit and for the main thread of the parent process to perform the clean-up of the temporary directory.Closes #6591 and addresses the Windows-centric bits that were added into #2379.