Fix the MySQL shell signal handling #853
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.
MySQL handles signals like an interrupt (ctrl+c) as a query interrupt / cancelation of the current input. This means it's not expected to have it shut down the CLI.
When we have the MySQL shell active, we should mask any signals and forward them straight to MySQL instead.
This sets up the logic to do so. It means we have to manually set up the initial context and signals instead of using signal.NotifyContext, since we need to be able to later on disable them which means access to the actual channel registed.
So we have to do this work manually and then pass through what we've registed, so we can disable it and setup the proper ones when we invoke the shell.
We also do the work to reverse it all, which is not strictly needed at the moment, but avoids making mistakes with it in the future if we would allow shutting down the shell and doing other commands.
Fixes #850