From 7567e08227ace6992d5c98d1936fd2c119f4b49b Mon Sep 17 00:00:00 2001 From: V Date: Tue, 11 Mar 2025 13:59:45 +0000 Subject: [PATCH] Disable stdout buffering globally This makes it possible to pipe output to other programs cleanly. --- src/main.c | 4 ++++ src/tty.c | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 1aba51b..6676bb3 100644 --- a/src/main.c +++ b/src/main.c @@ -61,6 +61,10 @@ int main(int argc, char *argv[]) /* Configure tty device */ tty_configure(); + /* Disable line buffering in stdout. This is necessary if we + * want things like local echo to work correctly. */ + setvbuf(stdout, NULL, _IONBF, 0); + /* Configure input terminal */ if (isatty(fileno(stdin))) { diff --git a/src/tty.c b/src/tty.c index ef2f154..c72fd67 100644 --- a/src/tty.c +++ b/src/tty.c @@ -1184,10 +1184,6 @@ void stdout_configure(void) { int status; - /* Disable line buffering in stdout. This is necessary if we - * want things like local echo to work correctly. */ - setvbuf(stdout, NULL, _IONBF, 0); - /* Save current stdout settings */ if (tcgetattr(STDOUT_FILENO, &stdout_old) < 0) {