summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-05-29 23:40:31 +0200
committerCarl Hetherington <cth@carlh.net>2025-05-29 23:40:31 +0200
commit49f5328f655feeb8217d1ed6c4e5613d5f34afd8 (patch)
tree83d1825b93127dccd3362b9382542d9867e72ef7
parent8b5f6159ca7a5d04225b2f3ee1572b4c67425c5e (diff)
Don't change directory when launching grk_compress.
-rw-r--r--src/lib/grok/messenger.cc21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/lib/grok/messenger.cc b/src/lib/grok/messenger.cc
index 29bda13b5..ce267759a 100644
--- a/src/lib/grok/messenger.cc
+++ b/src/lib/grok/messenger.cc
@@ -369,22 +369,15 @@ Messenger::getCompressedFrame(size_t frameId)
bool
Messenger::launch(std::string const& cmd, boost::filesystem::path const& dir)
{
- // Change the working directory
- if(!dir.empty())
- {
- boost::system::error_code ec;
- boost::filesystem::current_path(dir, ec);
- if (ec) {
- getMessengerLogger()->error("Error: failed to change the working directory");
- return false;
- }
- }
// Execute the command using std::async and std::system
- getMessengerLogger()->info(cmd.c_str());
- _async_result = std::async(std::launch::async, [cmd]() { return std::system(cmd.c_str()); });
- bool success = _async_result.valid();
- if (!success)
+ auto const cmd_with_dir = dir / cmd;
+ getMessengerLogger()->info(cmd_with_dir.string().c_str());
+ _async_result = std::async(std::launch::async, [cmd_with_dir]() { return std::system(cmd_with_dir.string().c_str()); });
+
+ auto const success = _async_result.valid();
+ if (!success) {
getMessengerLogger()->error("Grok launch failed");
+ }
return success;
}