]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
vipw: flush stdout before getting answer.
authorÉrico Nogueira <erico.erc@gmail.com>
Fri, 22 Oct 2021 17:28:50 +0000 (14:28 -0300)
committerÉrico Nogueira <erico.erc@gmail.com>
Fri, 22 Oct 2021 17:31:26 +0000 (14:31 -0300)
Otherwise the question is displayed only after the user presses Return,
and the program looks like it's hanging.

This happens at least on musl libc.

Reported by @loreb.

Signed-off-by: Érico Nogueira <erico.erc@gmail.com>
login-utils/vipw.c

index 8e63efde28b0b2021dbfb33f2b2b14623f99a8cb..f59948a443fcdf9391935f74abe435d08cf2fab3 100644 (file)
@@ -353,6 +353,7 @@ int main(int argc, char *argv[])
                 * which means they can be translated. */
                printf(_("Would you like to edit %s now [y/n]? "), orig_file);
 
+               fflush(stdout);
                if (fgets(response, sizeof(response), stdin) &&
                    rpmatch(response) == RPMATCH_YES)
                        edit_file(1);