18 #include <system_error>
25 class ProcessImpl :
public Process
28 int spawn(
const std::string& new_exe_name,
const fs::path& argv0_path,
int& pid)
override
30 return mp::SpawnProcess(pid, [&](
int fd) {
32 path.remove_filename();
37 int waitSpawned(
int pid)
override {
return mp::WaitProcess(pid); }
38 bool checkSpawned(
int argc,
char* argv[],
int& fd)
override
43 if (argc != 3 || strcmp(argv[1],
"-ipcfd") != 0) {
53 throw std::runtime_error(
strprintf(
"Invalid -ipcfd number '%s'", argv[2]));
60 std::unique_ptr<Process>
MakeProcess() {
return std::make_unique<ProcessImpl>(); }
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
static std::string PathToString(const path &path)
Convert path object to a byte string.
static path PathFromString(const std::string &string)
Convert byte string to path object.
std::unique_ptr< Process > MakeProcess()
Constructor for Process interface.
bool ParseInt32(std::string_view str, int32_t *out)
Convert string to signed 32-bit integer with strict parse error feedback.