From 1efa641105c99fcc184191e71ec1fcc41aaa0dfe Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Mon, 13 Jan 2020 14:29:58 -0800 Subject: [PATCH] Move some fflushes around in handle_builtin_output --- src/exec.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/exec.cpp b/src/exec.cpp index 79ab177cd..bdebca6f0 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -502,6 +502,10 @@ static bool handle_builtin_output(parser_t &parser, const std::shared_ptr errbuff.clear(); } + // Some historical behavior. + if (!outbuff.empty()) fflush(stdout); + if (!errbuff.empty()) fflush(stderr); + if (outbuff.empty() && errbuff.empty()) { // We do not need to construct a background process. // TODO: factor this job-status-setting stuff into a single place. @@ -514,8 +518,6 @@ static bool handle_builtin_output(parser_t &parser, const std::shared_ptr return true; } else { // Construct and run our background process. - fflush(stdout); - fflush(stderr); return run_internal_process(p, std::move(outbuff), std::move(errbuff), *io_chain); } }