From 6d61193286aedd4e514fd8f375b2000b95fff4fb Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Wed, 16 Feb 2022 00:46:57 -0800 Subject: [PATCH] Flush cout after each output line The default buffering behavior depends on whether the output is connected to an interactive device. This causes output lines to be buffered in an undesirable way when stdout is piped, which is how nix-eval-jobs is normally used. Let's fix it by flushing stdout explicitly. --- src/nix-eval-jobs.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nix-eval-jobs.cc b/src/nix-eval-jobs.cc index f9ca986..842040c 100644 --- a/src/nix-eval-jobs.cc +++ b/src/nix-eval-jobs.cc @@ -404,7 +404,7 @@ int main(int argc, char * * argv) } } else { auto state(state_.lock()); - std::cout << respString << "\n"; + std::cout << respString << "\n" << std::flush; } /* Add newly discovered job names to the queue. */