diff options
author | Dan McGee <dan@archlinux.org> | 2011-04-01 15:16:26 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-04-01 15:18:52 -0500 |
commit | d8d89d8d27794d493ed2aa9eba4649e6e3ff4a9d (patch) | |
tree | 07b32f59cc65835ae6b9045226683c4f3a201f19 /src | |
parent | 7f6d986ac93e3465db6a4ed5c3ac77b72d890e68 (diff) | |
download | pacman-d8d89d8d27794d493ed2aa9eba4649e6e3ff4a9d.tar.xz |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/pacman/util.c | 5 |
1 files changed, 5 insertions, 0 deletions
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) { |