mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-23 09:04:22 +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:
committed by
Rusty Russell
parent
ae4623c21a
commit
4dded23cd3
@@ -103,7 +103,7 @@ char *read_stdin_pass(char **reason)
|
|||||||
}
|
}
|
||||||
temp_term = current_term;
|
temp_term = current_term;
|
||||||
temp_term.c_lflag &= ~ECHO;
|
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.";
|
*reason = "Could not disable pass echoing.";
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ char *read_stdin_pass(char **reason)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Restore the original terminal */
|
/* 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.";
|
*reason = "Could not restore terminal options.";
|
||||||
free(passwd);
|
free(passwd);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user