commit 7effd7e7013dd385bf4cd6d4fbaea28475ab4886
Author: Tom Schwindl <[email protected]>
AuthorDate: Mon Aug 22 22:28:37 2022 +0200
Commit: Jan Klemkow <[email protected]>
CommitDate: Tue Sep 20 17:12:45 2022 +0200
lchat: flush earlier to make sure the initial prompt is displayed
The first fflush(3) occurs when the first character is read. In case we
need to wait a bit longer for this to happen, the initial prompt isn't
printed immediately and the program looks like it hung up.
diff --git a/lchat.c b/lchat.c
index d96d30e..3d820c2 100644
--- a/lchat.c
+++ b/lchat.c
@@ -335,6 +335,9 @@ main(int argc, char *argv[])
fputs(prompt, stdout);
for (;;) {
+ if (fflush(stdout) == EOF)
+ err(EXIT_FAILURE, "fflush");
+
errno = 0;
if (poll(pfd, nfds, INFTIM) == -1 && errno != EINTR)
err(EXIT_FAILURE, "poll");
@@ -445,9 +448,6 @@ main(int argc, char *argv[])
if (sl->rcur + prompt_len > 0)
printf("\033[%zuC", sl->rcur + prompt_len);
}
-
- if (fflush(stdout) == EOF)
- err(EXIT_FAILURE, "fflush");
}
return EXIT_SUCCESS;
}