From 07cd1c2185c765c1642a538806a78a8082c21d38 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Wed, 1 May 2024 06:49:43 +0200 Subject: [PATCH] fbdepth: enforce line-buffering on stdout By default, it's block-buffered if stdout is non-interactive, which affects ordering vs. stderr when using shell I/O redirections. This made reading DevCap logs super-confusing. --- utils/fbdepth.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/utils/fbdepth.c b/utils/fbdepth.c index 6bdcde6b..e5e7c101 100644 --- a/utils/fbdepth.c +++ b/utils/fbdepth.c @@ -316,6 +316,10 @@ int bool canonical_rota = false; #endif + // NOTE: Enforce line-buffering, to make I/O redirections less confusing (e.g., in DevCap logs), + // as we often mix stdout with stderr, and unlike stdout, stderr is always unbuffered (c.f., setvbuf(3)). + setlinebuf(stdout); + while ((opt = getopt_long(argc, argv, "d:hvqgGr:R:oOcCH:", opts, &opt_index)) != -1) { switch (opt) { case 'd':