SERVER-46007 ignore SIGINT when input password in stdin #1348
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.
Problem:
mongo causes os shell crash if we type ctrl + c when entering password in stdin.
In linux platform:
When we login to mongo server in shell with
-p
args but don't pass the password in the argument list, then mongo shell will prompt usEnter password:
to enter the password from stdin. At that time, if we sendctrl +c
(SIGINT) to stdin, the mongo shell will be closed, but at the same time, user's os shell will be crashed, and we can't input anything in the shell. We must close the whole shell session and login again to do other maintaining job.In windows platform, there is no such problem.
I think we should ignore
ctrl c
when we type password in stdin, just like other database client shell, such as mysql.Step to reproduce:
login a new linux shell, and use mongo shell:
Press enter key, then it will prompt us to enter password without echo in the screen:
At that time, we input some password, but don't press enter key. Instead of it, we type
ctrl c
:Because of SIGINT, the mongo shell closed normally, and returned to user's os main shell.
But in user's os main shell, we can't input anything more.
User's os main shell is crash now.
Signed-off-by: lifubang [email protected]