fix mount failure when path contains a space
This commit is contained in:
@@ -207,6 +207,7 @@ source_subdir
|
|||||||
spdlog
|
spdlog
|
||||||
spdlog_project
|
spdlog_project
|
||||||
st_ctim
|
st_ctim
|
||||||
|
startupinfoa
|
||||||
static-libgcc
|
static-libgcc
|
||||||
static-libstdc++
|
static-libstdc++
|
||||||
stbuf
|
stbuf
|
||||||
|
@@ -38,6 +38,7 @@
|
|||||||
#include <boost/process/v1/args.hpp>
|
#include <boost/process/v1/args.hpp>
|
||||||
#include <boost/process/v1/child.hpp>
|
#include <boost/process/v1/child.hpp>
|
||||||
#include <boost/process/v1/io.hpp>
|
#include <boost/process/v1/io.hpp>
|
||||||
|
namespace bp1 = boost::process::v1;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
[[nodiscard]] auto decrypt(std::string_view data, std::string_view password)
|
[[nodiscard]] auto decrypt(std::string_view data, std::string_view password)
|
||||||
@@ -720,19 +721,35 @@ 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"}));
|
auto cmdline = fmt::format("{}{}{}", '"', repertory_binary_, '"');
|
||||||
args.insert(std::next(args.begin()), "/c");
|
for (const auto &arg : args) {
|
||||||
args.insert(std::next(args.begin(), 2U), "start");
|
cmdline += " ";
|
||||||
args.insert(std::next(args.begin(), 3U), "");
|
if (arg.find_first_of(" \t") != std::string::npos) {
|
||||||
args.insert(std::next(args.begin(), 4U), "/MIN");
|
cmdline += fmt::format("{}{}{}", '"', arg, '"');
|
||||||
args.insert(std::next(args.begin(), 5U), repertory_binary_);
|
} else {
|
||||||
|
cmdline += arg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
STARTUPINFOA start_info{};
|
||||||
|
start_info.cb = sizeof(start_info);
|
||||||
|
|
||||||
|
PROCESS_INFORMATION proc_info{};
|
||||||
|
auto result = ::CreateProcessA(
|
||||||
|
nullptr, &cmdline[0U], nullptr, nullptr, FALSE,
|
||||||
|
CREATE_NEW_PROCESS_GROUP | DETACHED_PROCESS, nullptr,
|
||||||
|
utils::path::get_parent_path(repertory_binary_).c_str(), &start_info,
|
||||||
|
&proc_info);
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
::CloseHandle(proc_info.hProcess);
|
||||||
|
::CloseHandle(proc_info.hThread);
|
||||||
|
}
|
||||||
#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);
|
||||||
@@ -741,10 +758,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);
|
||||||
@@ -778,10 +791,8 @@ auto handlers::launch_process(provider_type prov, std::string_view name,
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::process::v1::ipstream out;
|
bp1::ipstream out;
|
||||||
boost::process::v1::child proc(repertory_binary_,
|
bp1::child proc(repertory_binary_, bp1::args(args), bp1::std_out > out);
|
||||||
boost::process::v1::args(args),
|
|
||||||
boost::process::v1::std_out > out);
|
|
||||||
|
|
||||||
std::string data;
|
std::string data;
|
||||||
std::string line;
|
std::string line;
|
||||||
|
Reference in New Issue
Block a user