Skip to content

Commit e7ef9a4

Browse files
author
Paweł Andruszkiewicz
committed
BUG#36861912 MySQL Shell behavior on Console Exit
When running Shell via SSH (i.e. putty), if a command was entered in the prompt and then the SSH connection was closed, it was possible that this command was executed, even though the enter key was not pressed. The linenoise module (which is used by Shell to read from terminal) was not treating a situation where stdin is closed as an error. Instead, it returned buffer holding the current contents of prompt, which was then executed by Shell. The linenoise module was adjusted to signal when stdin is closed, in such case Shell aborts execution. Change-Id: I494b0db0929f5b0b95d7fe871b95c4f4dc63246b
1 parent 15f7eb1 commit e7ef9a4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

ext/linenoise-ng/src/linenoise.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -2832,6 +2832,9 @@ int InputBuffer::getInputLine(PromptBase &pi) {
28322832
} else if (c == ctrlChar('D')) {
28332833
keyType = 2;
28342834
}
2835+
} else {
2836+
// reading was interrupted (i.e. stdin was closed)
2837+
keyType = 3;
28352838
}
28362839

28372840
#ifndef _WIN32

src/mysqlsh/cmdline_shell.cc

+5
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,11 @@ char *Command_line_shell::readline(const char *prompt) {
916916
console->enable_global_pager();
917917
}
918918

919+
if (3 == linenoiseKeyType()) {
920+
// reading was interrupted
921+
return nullptr;
922+
}
923+
919924
if (!tmp) {
920925
switch (linenoiseKeyType()) {
921926
case 1: // ^C

0 commit comments

Comments
 (0)