From 3d92cff726d6fb9f69254241cb6169bed69e6ddb Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Wed, 8 Apr 2020 16:39:28 +0200 Subject: [PATCH] lookip: Use line buffering for stdout Otherwise, the output is buffered when e.g. piping the output to another command (or file). And it avoids having to call fflush() in the interactive mode. Fixes #3404. --- src/libcharon/plugins/lookip/lookip.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libcharon/plugins/lookip/lookip.c b/src/libcharon/plugins/lookip/lookip.c index d473c7022e..6d82e1a172 100644 --- a/src/libcharon/plugins/lookip/lookip.c +++ b/src/libcharon/plugins/lookip/lookip.c @@ -203,7 +203,6 @@ static int interactive(int fd) int res; printf("> "); - fflush(stdout); if (fgets(line, sizeof(line), stdin)) { @@ -266,6 +265,8 @@ int main(int argc, char *argv[]) return 1; } + setvbuf(stdout, NULL, _IOLBF, 0); + if (argc == 1) { res = interactive(fd); -- 2.47.2