1
0
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:
Dan McGee 2011-04-01 15:16:26 -05:00
parent 7f6d986ac9
commit d8d89d8d27

View File

@ -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) {