Skip to content

Commit

Permalink
fbdepth: enforce line-buffering on stdout
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
NiLuJe committed May 1, 2024
1 parent 862dba8 commit 07cd1c2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions utils/fbdepth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down

0 comments on commit 07cd1c2

Please sign in to comment.