Messages in this thread | | | From | David Laight <> | Subject | RE: [PATCH v2] Unbuffered output when pipe/tee to a file | Date | Sat, 11 Dec 2021 17:10:13 +0000 |
| |
From: Arnaldo Carvalho de Melo > Sent: 09 December 2021 18:51 ... > > diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c > > index 8cb5a1c3489e..d92ae4efd2e6 100644 > > --- a/tools/perf/tests/builtin-test.c > > +++ b/tools/perf/tests/builtin-test.c > > @@ -606,6 +606,9 @@ int cmd_test(int argc, const char **argv) > > if (ret < 0) > > return ret; > > > > + /* Unbuffered output */ > > + setvbuf(stdout, NULL, _IONBF, 0); > > +
You only want _IOLBF (line buffered).
Otherwise you are likely to get a lot of write() system calls. Even multiple ones from the same printf().
Although it can be better just to ensure there is a fflush(stdout) inside the loop.
David
- Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
| |