From 33e0066b4c0bb2a317bc5bdcb18ee9aa57baba46 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Fri, 14 Mar 2025 20:49:14 -0500 Subject: [PATCH] synchronous command --- repertory/repertory/include/ui/handlers.hpp | 1 + repertory/repertory/src/ui/handlers.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/repertory/repertory/include/ui/handlers.hpp b/repertory/repertory/include/ui/handlers.hpp index af9c7849..d0ce5ec6 100644 --- a/repertory/repertory/include/ui/handlers.hpp +++ b/repertory/repertory/include/ui/handlers.hpp @@ -47,6 +47,7 @@ private: private: console_consumer console; + mutable std::mutex mtx_; private: void handle_get_mount(auto &&req, auto &&res) const; diff --git a/repertory/repertory/src/ui/handlers.cpp b/repertory/repertory/src/ui/handlers.cpp index d8d6bea6..a15f96a6 100644 --- a/repertory/repertory/src/ui/handlers.cpp +++ b/repertory/repertory/src/ui/handlers.cpp @@ -355,6 +355,7 @@ auto handlers::launch_process(provider_type prov, std::string_view name, auto cmd_line = fmt::format(R"({} {} {})", repertory_binary_, str_type, args); + mutex_lock lock(mtx_); if (background) { #if defined(_WIN32) system(fmt::format(R"(start "" /b {})", cmd_line).c_str()); @@ -378,8 +379,8 @@ auto handlers::launch_process(provider_type prov, std::string_view name, std::string data; std::array buffer{}; - while (feof(pipe) == 0) { - while (fgets(buffer.data(), buffer.size(), pipe) != nullptr) { + while (std::feof(pipe) == 0) { + while (std::fgets(buffer.data(), buffer.size(), pipe) != nullptr) { data += buffer.data(); } }