From: Tobias Brunner Date: Wed, 8 Apr 2020 14:39:28 +0000 (+0200) Subject: lookip: Use line buffering for stdout X-Git-Tag: 5.9.0dr1~25 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3d92cff726d6fb9f69254241cb6169bed69e6ddb;p=thirdparty%2Fstrongswan.git 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. --- 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);