mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-19 05:44:12 +01:00
hsmtool: use flag TCSANOW when disabling tty ECHO, fixes rare hang in test_hsm*
No idea why TCSAFLUSH was used, could not find anything in PR comments. Also cannot explain exactly what causes the problem, but the hang can be reproduced *with* TCSAFLUSH and not with TCSANOW. According to termios doc: TCSANOW the change occurs immediately. TCSAFLUSH the change occurs after all output written to the object referred by fd has been transmitted, and all input that has been received but not read will be discarded before the change is made.
This commit is contained in:
parent
ae4623c21a
commit
4dded23cd3
@ -103,7 +103,7 @@ char *read_stdin_pass(char **reason)
|
||||
}
|
||||
temp_term = current_term;
|
||||
temp_term.c_lflag &= ~ECHO;
|
||||
if (tcsetattr(fileno(stdin), TCSAFLUSH, &temp_term) != 0) {
|
||||
if (tcsetattr(fileno(stdin), TCSANOW, &temp_term) != 0) {
|
||||
*reason = "Could not disable pass echoing.";
|
||||
return NULL;
|
||||
}
|
||||
@ -114,7 +114,7 @@ char *read_stdin_pass(char **reason)
|
||||
}
|
||||
|
||||
/* Restore the original terminal */
|
||||
if (tcsetattr(fileno(stdin), TCSAFLUSH, ¤t_term) != 0) {
|
||||
if (tcsetattr(fileno(stdin), TCSANOW, ¤t_term) != 0) {
|
||||
*reason = "Could not restore terminal options.";
|
||||
free(passwd);
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user