process¶
| Type | Class |
| Namespace | conjure::core |
| Include File Path | engine/include/conjure/core/process.h |
| Source File Path | engine/src/core/system/process.cpp |
| API ↗ | Processes, libraries and images |
Syntax¶
Constructors¶
| Access | Signature | Description |
|---|---|---|
| public | process(); | |
| public | process(
process &&other) noexcept; |
Important
Copy constructor and assignment has been deleted.
Destructors¶
| Access | Signature | Description |
|---|---|---|
| public | ~process(); |
Variables¶
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| public | KILLED_ | static constexpr i32 | -1 | Exit code reported for a child killed by kill() or by the timeout, and for a child whose exit status was lost (POSIX: SIGCHLD ignored by the host, or the child reaped elsewhere), so a lost status never reads as success. |
| public | MAX_ | static constexpr f64 | 1.0e9 | Largest timeout honoured (about 31 years); larger finite values are clamped to it. |
| private | mState | std::unique_ptr<state> | {} |
Functions¶
Public¶
is_running¶
is_running¶[[nodiscard]] bool is_running() const noexcept;True while the child has not exited and wait() has not been called.
kill¶
kill¶void kill() noexcept;Kills the child and every process it spawned, including descendants that outlived the child itself. No-op once wait() returned. wait() still has to be called to collect the result.
process_id¶
process_id¶[[nodiscard]] u32 process_id() const noexcept;The operating system's identifier of the child, 0 when not started.
read_error¶
read_error¶usize read_error(
std::string &out);Appends the standard error captured since the previous call and returns the number of bytes appended. Never blocks.
read_output¶
read_output¶usize read_output(
std::string &out);Appends the standard output captured since the previous call and returns the number of bytes appended. Never blocks.
run¶
run¶[[nodiscard]] static result<process_result> run(
const process_desc &desc);Starts the child and blocks until it exits or the timeout kills it. Fails with INVALID_ARGUMENT for an inconsistent description, NOT_FOUND when the executable or working directory does not exist, PERMISSION_DENIED or BACKEND_FAILURE when the operating system refuses to start it. A non-zero exit code is not an error.
start¶
start¶[[nodiscard]] static result<process> start(
const process_desc &desc);Starts the child and returns immediately. Same failures as run().
wait¶
wait¶[[nodiscard]] result<process_result> wait();Blocks until the child exits and its captured output is drained (killing the whole tree when the description's timeout elapses first), then returns its exit code and the output not yet consumed by read_output() / read_error(). Without a timeout a descendant that inherited the output pipe delays the return until it closes it. Fails with INVALID_STATE when the process was never started or wait() was already called.