From 34a9b65587a7d704db0344e859511af4a6756c89 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Nogueira?= <erico.erc@gmail.com>
Date: Fri, 22 Oct 2021 14:28:50 -0300
Subject: [PATCH] vipw: flush stdout before getting answer.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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 | 1 +
 1 file changed, 1 insertion(+)

diff --git a/login-utils/vipw.c b/login-utils/vipw.c
index 38953b7..bd0bac5 100644
--- a/login-utils/vipw.c
+++ b/login-utils/vipw.c
@@ -364,6 +364,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);
-- 
2.27.0

