Use line buffering on stdout
authorKris Davis <Kris.Davis@hgst.com>
Wed, 30 Sep 2015 16:00:00 +0000 (18:00 +0200)
committerJens Axboe <axboe@fb.com>
Wed, 30 Sep 2015 16:00:00 +0000 (18:00 +0200)
Line Buffer stdio to prevent multi-thread output from
mixing within a line

Signed-off-by: Jens Axboe <axboe@fb.com>
fio.c

diff --git a/fio.c b/fio.c
index ee6eae2..bafbd48 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -42,6 +42,12 @@ int main(int argc, char *argv[], char *envp[])
        if (parse_options(argc, argv))
                goto done;
 
+       /*
+        * line buffer stdout to avoid output lines from multiple
+        * threads getting mixed
+        */
+       setvbuf(stdout, NULL, _IOLBF, 0);
+
        fio_time_init();
 
        if (nr_clients) {