From 46dd4112732b90314d05bf9c946871408322868d Mon Sep 17 00:00:00 2001 From: Bananymous Date: Tue, 5 Aug 2025 03:06:40 +0300 Subject: [PATCH] LibC: fflush stdout when reading from stdin This is the *intended behaviour* per ISO C specification --- userspace/libraries/LibC/stdio.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/userspace/libraries/LibC/stdio.cpp b/userspace/libraries/LibC/stdio.cpp index 567f745e..a020a250 100644 --- a/userspace/libraries/LibC/stdio.cpp +++ b/userspace/libraries/LibC/stdio.cpp @@ -542,6 +542,9 @@ int getc_unlocked(FILE* file) if (file->eof) return EOF; + if (file == stdin && file->buffer_type == _IOLBF && stdout->buffer_type == _IOLBF && stdout->buffer_idx) + fflush(stdout); + // read characters from ungetc if (file->unget_buf_idx) {