fix mount failure when path contains a space

This commit is contained in:
2025-07-30 07:56:11 -05:00
parent d8774ba7f7
commit 5357486659

View File

@@ -720,23 +720,17 @@ auto handlers::launch_process(provider_type prov, std::string_view name,
recur_mutex_lock inst_lock(inst_mtx);
if (background) {
#if defined(_WIN32)
std::array<char, MAX_PATH + 1U> path{};
::GetSystemDirectoryA(path.data(), path.size());
args.insert(args.begin(), "--hidden");
args.insert(args.begin(), utils::path::combine(path.data(), {"cmd.exe"}));
args.insert(std::next(args.begin()), "/c");
args.insert(std::next(args.begin(), 2U), "start");
args.insert(std::next(args.begin(), 3U), "");
args.insert(std::next(args.begin(), 4U), "/MIN");
if (utils::string::contains(repertory_binary_, " ")) {
args.insert(std::next(args.begin(), 5U), "\"" + repertory_binary_ + "\"");
} else {
args.insert(std::next(args.begin(), 5U), repertory_binary_);
}
boost::process::v1::child proc(repertory_binary_,
boost::process::v1::args(args),
boost::process::v1::std_out.close(),
boost::process::v1::std_err.close(),
boost::process::v1::std_in.close());
proc.detach();
#else // !defined(_WIN32)
args.insert(args.begin(), "-f");
args.insert(args.begin(), repertory_binary_);
#endif // defined(_WIN32)
args.insert(std::next(args.begin()), "-f");
std::vector<const char *> exec_args;
exec_args.reserve(args.size() + 1U);
@@ -745,10 +739,6 @@ auto handlers::launch_process(provider_type prov, std::string_view name,
}
exec_args.push_back(nullptr);
#if defined(_WIN32)
_spawnv(_P_DETACH, exec_args.at(0U),
const_cast<char *const *>(exec_args.data()));
#else // !defined(_WIN32)
auto pid = fork();
if (pid < 0) {
exit(1);