From cb3fc22ac1a95eda0843aa641720b52063c3b74c Mon Sep 17 00:00:00 2001 From: Alessandro Da Rugna Date: Sun, 29 Oct 2017 21:02:33 +0100 Subject: add option: flush stdout Added the option to forcefully flush STDOUT, which may be useful when running the miner through a pipe instead than a shell. If STDOUT is a shell, it's unbuffered by default. If STDOUT is a pipe, it's buffered by default. --- xmrstak/misc/console.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'xmrstak/misc/console.cpp') diff --git a/xmrstak/misc/console.cpp b/xmrstak/misc/console.cpp index ba34bb3..ce63bcb 100644 --- a/xmrstak/misc/console.cpp +++ b/xmrstak/misc/console.cpp @@ -156,6 +156,7 @@ printer::printer() { verbose_level = LINF; logfile = nullptr; + b_flush_stdout = false; } bool printer::open_logfile(const char* file) @@ -193,6 +194,11 @@ void printer::print_msg(verbosity verbose, const char* fmt, ...) std::unique_lock lck(print_mutex); fputs(buf, stdout); + if (b_flush_stdout) + { + fflush(stdout); + } + if(logfile != nullptr) { fputs(buf, logfile); -- cgit v1.1