mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-23 08:18:51 -05:00
Ensure stdout/stderr are flushed when asking questions
Addresses FS#23492, where the question was shown without knowing what one was answering to. Ensure we flush our output streams before printing the question, and flush the stream on which we ask the question before waiting for an answer. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
7f6d986ac9
commit
d8d89d8d27
@ -878,6 +878,10 @@ static int question(short preset, char *fmt, va_list args)
|
||||
stream = stderr;
|
||||
}
|
||||
|
||||
/* ensure all text makes it to the screen before we prompt the user */
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
|
||||
vfprintf(stream, fmt, args);
|
||||
|
||||
if(preset) {
|
||||
@ -891,6 +895,7 @@ static int question(short preset, char *fmt, va_list args)
|
||||
return(preset);
|
||||
}
|
||||
|
||||
fflush(stream);
|
||||
if(fgets(response, sizeof(response), stdin)) {
|
||||
strtrim(response);
|
||||
if(strlen(response) == 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user