cubos::core::thread::Process class final

Provides a cross-platform way to spawn child processes.

Constructors, destructors, conversion operators

Process() defaulted
Default constructor.
Process(Process&& other) noexcept
Move constructor.

Public functions

auto operator=(Process&& other) -> Process& noexcept
Move assignment operator.
auto start(const std::string& command, const std::vector<std::string>& args = {}, const std::string& cwd = "") -> bool
Starts a new process.
void kill()
Kills the process.
auto wait() -> bool
Waits for the process to finish.
auto wait(int& status) -> bool
Waits for the process to finish.
auto started() const -> bool
Checks whether the process has been started.

Function documentation

bool cubos::core::thread::Process::start(const std::string& command, const std::vector<std::string>& args = {}, const std::string& cwd = "")

Starts a new process.

Parameters
command Command to execute.
args Arguments to pass to the command.
cwd Working directory for the new process.
Returns Whether the process was started successfully.

bool cubos::core::thread::Process::wait()

Waits for the process to finish.

Returns Whether the process exited normally.

bool cubos::core::thread::Process::wait(int& status)

Waits for the process to finish.

Parameters
status Exit code of the process, if it exited normally.
Returns Whether the process exited normally.

bool cubos::core::thread::Process::started() const

Checks whether the process has been started.

Returns Whether the process has been started.