From 3b366f993c0e66e179a8482b2adb974a533374d3 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 20 Jun 2015 02:08:04 +0200 Subject: [PATCH] Make stdout/stderr line buffered MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This improves the behaviour with print()ing for debugging, when the output is redirected to a file. I was using `setbuf(…, 0)` initially, but it makes sense to buffer it per line. This uses `setvbuf` instead of `setlinebuf`, which might not be available everywhere. Closes https://github.com/awesomeWM/awesome/pull/267 --- awesome.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/awesome.c b/awesome.c index 046ea3fcd..ed920e49f 100644 --- a/awesome.c +++ b/awesome.c @@ -325,6 +325,10 @@ main(int argc, char **argv) { NULL, 0, NULL, 0 } }; + /* Make stdout/stderr line buffered. */ + setvbuf(stdout, NULL, _IOLBF, 0); + setvbuf(stderr, NULL, _IOLBF, 0); + /* clear the globalconf structure */ p_clear(&globalconf, 1); globalconf.keygrabber = LUA_REFNIL;