From d8d89d8d27794d493ed2aa9eba4649e6e3ff4a9d Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 1 Apr 2011 15:16:26 -0500 Subject: 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 --- src/pacman/util.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pacman/util.c b/src/pacman/util.c index 83368085..c7d98540 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -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) { -- cgit v1.2.3-55-g3dc8