From f03a22338396b5449437fc3a907e4d8372ce9b81 Mon Sep 17 00:00:00 2001 From: eidheim Date: Tue, 23 Mar 2021 17:44:42 +0100 Subject: [PATCH] Relted to #444: added Linux specific line buffering on async processes --- src/terminal.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/terminal.cpp b/src/terminal.cpp index d900baa..f58fb21 100644 --- a/src/terminal.cpp +++ b/src/terminal.cpp @@ -272,8 +272,19 @@ std::shared_ptr Terminal::async_process(const std::stri scroll_to_bottom(); stdin_buffer.clear(); +#if !defined(__APPLE__) && !defined(_WIN32) + static auto stdbuf = filesystem::find_executable("stdbuf").string(); +#endif + auto process = std::make_shared( - "STDBUF1=L " + command, path.string(), +#if defined(__APPLE__) + "STDBUF1=L " + command, +#elif defined(_WIN32) + command, +#else + !stdbuf.empty() ? std::vector{stdbuf, "-oL", "/bin/sh", "-c", command} : std::vector{"/bin/sh", "-c", command}, +#endif + path.string(), [this, quiet](const char *bytes, size_t n) { if(!quiet) { // Print stdout message sequentially to avoid the GUI becoming unresponsive