1 Star 0 Fork 68

hexiaole1994/util-linux

forked from src-openEuler/util-linux 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-vipw-flush-stdout-before-getting-answer.patch 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
shangyibin 提交于 2022-06-20 17:29 +08:00 . sync patches
From 56bacb552d017858751aac208987604f7c9387c7 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 f178c8f..bf76f51 100644
--- a/login-utils/vipw.c
+++ b/login-utils/vipw.c
@@ -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);
--
1.8.3.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hexiaole1994/util-linux.git
git@gitee.com:hexiaole1994/util-linux.git
hexiaole1994
util-linux
util-linux
master

搜索帮助