From e3e56f579b7d31116e18157df857af7f0a55983e Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 8 Jul 2016 11:03:55 +0200 Subject: [PATCH] src: disable stdio buffering Disable stdio buffering, it interacts poorly with printf() calls from elsewhere in the program (e.g., any logging from V8.) Unbreaks among other things the `--trace_debug_json` switch. Undoes commit 0966ab99 ("src: force line buffering for stderr"), which in retrospect is not a proper fix. Turning on line buffering fixed a flaky test on SmartOS but the test wasn't failing on other platforms, where stderr wasn't line-buffered either. Mark the test flaky again, it failed once in a run of 333 tries on the smartos-64 buildbot. Disabling buffering should be safe even when mixed with non-blocking stdio I/O because libuv goes to great lengths to reopen the tty file descriptors and falls back to blocking I/O when that fails. PR-URL: https://github.com/nodejs/node/pull/7610 Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott --- src/node_main.cc | 5 ++++- test/parallel/parallel.status | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/node_main.cc b/src/node_main.cc index 7cc5918b228ba8..2cd7502a2444fb 100644 --- a/src/node_main.cc +++ b/src/node_main.cc @@ -42,7 +42,10 @@ int wmain(int argc, wchar_t *wargv[]) { #else // UNIX int main(int argc, char *argv[]) { - setvbuf(stderr, NULL, _IOLBF, 1024); + // Disable stdio buffering, it interacts poorly with printf() + // calls elsewhere in the program (e.g., any logging from V8.) + setvbuf(stdout, nullptr, _IONBF, 0); + setvbuf(stderr, nullptr, _IONBF, 0); return node::Start(argc, argv); } #endif diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index c907c30a5cb43a..fc4d131b72f874 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -15,6 +15,7 @@ test-tick-processor : PASS,FLAKY [$system==macos] [$system==solaris] # Also applies to SmartOS +test-debug-signal-cluster : PASS,FLAKY [$system==freebsd]