Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the MySQL shell signal handling #853

Merged
merged 3 commits into from
Apr 18, 2024

Conversation

dbussink
Copy link
Collaborator

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

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.
@dbussink dbussink requested a review from a team as a code owner April 18, 2024 14:51
@dbussink dbussink merged commit e37d329 into main Apr 18, 2024
1 check passed
@dbussink dbussink deleted the dbussink/fix-shell-signal-handling branch April 18, 2024 15:22
@dbussink dbussink mentioned this pull request Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Do not disconnect pscale CLI on CTRL+C
3 participants