]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
lookip: Use line buffering for stdout
authorTobias Brunner <tobias@strongswan.org>
Wed, 8 Apr 2020 14:39:28 +0000 (16:39 +0200)
committerTobias Brunner <tobias@strongswan.org>
Thu, 7 May 2020 13:05:55 +0000 (15:05 +0200)
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

index d473c7022e17eedb8e01a80d9fa34dca20d3b612..6d82e1a172ca89f20e981f38dd9e2d75836793e2 100644 (file)
@@ -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);