Process update and UdpSocket
CI / GCC 16 / C++26 / sanitizers (pull_request) Has been cancelled
CI / GCC 16 / C++26 / werror (pull_request) Has been cancelled
CI / GCC 16 / C++26 / default (pull_request) Has been cancelled

Signed-off-by: faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-07-11 21:40:52 +03:00
1 parent 827c9e150a
commit 7ca0e1b62e
5 files changed
+241 -1

No files matched your search

+31 -1
View File
@@ -14,7 +14,7 @@ namespace Void::Process
std::chrono::milliseconds)
{
return Void::Result::fail("Process::run: not implemented on Windows");
}
}
Void::Result::Result<Output, Void::Result::Error>
run_streaming(const std::filesystem::path&,
@@ -32,6 +32,13 @@ namespace Void::Process
{
return Void::Result::fail("Process::shell: not implemented on Windows");
}
Void::Result::Result<void, Void::Result::Error>
reexec(const std::filesystem::path&,
const std::vector<std::string>&)
{
return Void::Result::fail("Process::reexec: not implemented on Windows");
}
} // namespace Void::Process
#else // POSIX
@@ -316,6 +323,29 @@ namespace Void::Process
return run("/bin/sh", {"-c", std::string{command}}, {}, timeout);
}
Void::Result::Result<void, Void::Result::Error>
reexec(const std::filesystem::path& executable,
const std::vector<std::string>& arguments)
{
if (executable.empty()) {
return Void::Result::fail("Process::reexec: executable is empty");
}
std::vector<std::string> owned;
owned.reserve(arguments.size() + 1);
owned.push_back(executable.string());
owned.insert(owned.end(), arguments.begin(), arguments.end());
std::vector<char*> argv;
argv.reserve(owned.size() + 1);
for (auto& argument : owned) {
argv.push_back(argument.data());
}
argv.push_back(nullptr);
::execv(executable.c_str(), argv.data());
return Void::Result::fail(std::format(
"Process::reexec: execv '{}' failed: {}", executable.string(),
std::strerror(errno)));
}
} // namespace Void::Process
#endif // _WIN32