clients/disorder.c: Force line buffering when writing log.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 21 Jul 2018 14:26:21 +0000 (15:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 21 Jul 2018 14:26:21 +0000 (15:26 +0100)
Otherwise it looks fine on a terminal, but that's not very useful.  If a
program tries to read the log over a pipe, then it sees nothing for a
good long while until the buffer gets flushed.

This change is specific to the `log' command.  Output for other commands
comes out at the same time anyway.

clients/disorder.c

index dc86a65..b9b2bb2 100644 (file)
@@ -348,6 +348,7 @@ static void cf_set_volume(char **argv) {
 }
 
 static void cf_log(char attribute((unused)) **argv) {
+  setvbuf(stdout, 0, _IOLBF, BUFSIZ);
   if(disorder_log(getclient(), sink_stdio("stdout", stdout))) exit(EXIT_FAILURE);
 }