fix mount failure when path contains a space
This commit is contained in:
@@ -720,23 +720,17 @@ auto handlers::launch_process(provider_type prov, std::string_view name,
|
|||||||
recur_mutex_lock inst_lock(inst_mtx);
|
recur_mutex_lock inst_lock(inst_mtx);
|
||||||
if (background) {
|
if (background) {
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
std::array<char, MAX_PATH + 1U> path{};
|
args.insert(args.begin(), "--hidden");
|
||||||
::GetSystemDirectoryA(path.data(), path.size());
|
|
||||||
|
|
||||||
args.insert(args.begin(), utils::path::combine(path.data(), {"cmd.exe"}));
|
boost::process::v1::child proc(repertory_binary_,
|
||||||
args.insert(std::next(args.begin()), "/c");
|
boost::process::v1::args(args),
|
||||||
args.insert(std::next(args.begin(), 2U), "start");
|
boost::process::v1::std_out.close(),
|
||||||
args.insert(std::next(args.begin(), 3U), "");
|
boost::process::v1::std_err.close(),
|
||||||
args.insert(std::next(args.begin(), 4U), "/MIN");
|
boost::process::v1::std_in.close());
|
||||||
if (utils::string::contains(repertory_binary_, " ")) {
|
proc.detach();
|
||||||
args.insert(std::next(args.begin(), 5U), "\"" + repertory_binary_ + "\"");
|
|
||||||
} else {
|
|
||||||
args.insert(std::next(args.begin(), 5U), repertory_binary_);
|
|
||||||
}
|
|
||||||
#else // !defined(_WIN32)
|
#else // !defined(_WIN32)
|
||||||
args.insert(args.begin(), "-f");
|
|
||||||
args.insert(args.begin(), repertory_binary_);
|
args.insert(args.begin(), repertory_binary_);
|
||||||
#endif // defined(_WIN32)
|
args.insert(std::next(args.begin()), "-f");
|
||||||
|
|
||||||
std::vector<const char *> exec_args;
|
std::vector<const char *> exec_args;
|
||||||
exec_args.reserve(args.size() + 1U);
|
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);
|
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();
|
auto pid = fork();
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
exit(1);
|
exit(1);
|
||||||
|
Reference in New Issue
Block a user