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.
This commit is contained in:
Tobias Brunner 2020-04-08 16:39:28 +02:00
parent 7ae4ced06f
commit 3d92cff726
1 changed files with 2 additions and 1 deletions

View 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);