Cross-platform child process with timeout, cancellation, and line-by-line output callbacks.
More...
#include <child_process.hpp>
|
| | ChildProcess () |
| | ~ChildProcess () |
| | ChildProcess (ChildProcess &&) noexcept |
| ChildProcess & | operator= (ChildProcess &&) noexcept |
| | ChildProcess (const ChildProcess &)=delete |
| ChildProcess & | operator= (const ChildProcess &)=delete |
| bool | start (const std::string &command, const std::vector< std::string > &args, const ProcessOptions &options={}) |
| | Non-blocking: start a command.
|
| bool | start_with_standard_input (const std::string &command, const std::vector< std::string > &args, std::span< const std::uint8_t > bytes, const ProcessOptions &options={}) |
| | Start with bytes delivered through a private inherited standard-input pipe.
|
| bool | start_with_standard_input (const std::string &command, const std::vector< std::string > &args, const StandardInputByteProvider &provider, const ProcessOptions &options={}) |
| | Spawn the child blocked on a private inherited standard-input pipe, then obtain the bytes from a provider that receives the actual child id.
|
| bool | start_with_standard_input_channel (const std::string &command, const std::vector< std::string > &args, const StandardInputChannelSession &session, const ProcessOptions &options={}) |
| | Spawn with a private duplex standard-input channel and transfer the parent endpoint to a post-spawn session.
|
| bool | is_running () const |
| | Check if the started process is still running.
|
| int | process_id () const |
| | Return the child process id, or -1 if no process has started.
|
| void | cancel () |
| | Request cancellation.
|
| ProcessResult | wait () |
| | Wait for the process to complete and return the result.
|
| std::string | read_available_output () |
| | Read any available output without blocking (for non-blocking mode).
|
|
| static ProcessResult | run (const std::string &command, const std::vector< std::string > &args, const ProcessOptions &options={}) |
| | Blocking: run a command and return the result.
|
Cross-platform child process with timeout, cancellation, and line-by-line output callbacks.
Uses posix_spawn on POSIX (sandbox-compatible for AU plugins on macOS) and CreateProcess on Windows.
◆ ChildProcess() [1/3]
| pulp::platform::ChildProcess::ChildProcess |
( |
| ) |
|
◆ ~ChildProcess()
| pulp::platform::ChildProcess::~ChildProcess |
( |
| ) |
|
◆ ChildProcess() [2/3]
| pulp::platform::ChildProcess::ChildProcess |
( |
ChildProcess && | | ) |
|
|
noexcept |
◆ ChildProcess() [3/3]
| pulp::platform::ChildProcess::ChildProcess |
( |
const ChildProcess & | | ) |
|
|
delete |
◆ cancel()
| void pulp::platform::ChildProcess::cancel |
( |
| ) |
|
Request cancellation.
Sends SIGTERM to the private process group on POSIX (or TerminateProcess on Windows), waits a short grace period, then sends SIGKILL if the child or a descendant is still alive.
◆ is_running()
| bool pulp::platform::ChildProcess::is_running |
( |
| ) |
const |
Check if the started process is still running.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ process_id()
| int pulp::platform::ChildProcess::process_id |
( |
| ) |
const |
Return the child process id, or -1 if no process has started.
After wait() or cancel(), the OS may reuse this id; do not use it to signal a completed process.
◆ read_available_output()
| std::string pulp::platform::ChildProcess::read_available_output |
( |
| ) |
|
Read any available output without blocking (for non-blocking mode).
◆ run()
| ProcessResult pulp::platform::ChildProcess::run |
( |
const std::string & | command, |
|
|
const std::vector< std::string > & | args, |
|
|
const ProcessOptions & | options = {} ) |
|
static |
Blocking: run a command and return the result.
◆ start()
| bool pulp::platform::ChildProcess::start |
( |
const std::string & | command, |
|
|
const std::vector< std::string > & | args, |
|
|
const ProcessOptions & | options = {} ) |
Non-blocking: start a command.
◆ start_with_standard_input() [1/2]
| bool pulp::platform::ChildProcess::start_with_standard_input |
( |
const std::string & | command, |
|
|
const std::vector< std::string > & | args, |
|
|
const StandardInputByteProvider & | provider, |
|
|
const ProcessOptions & | options = {} ) |
Spawn the child blocked on a private inherited standard-input pipe, then obtain the bytes from a provider that receives the actual child id.
Provider rejection, exceptions, oversize output, or delivery failure terminate and join the child before this returns false.
◆ start_with_standard_input() [2/2]
| bool pulp::platform::ChildProcess::start_with_standard_input |
( |
const std::string & | command, |
|
|
const std::vector< std::string > & | args, |
|
|
std::span< const std::uint8_t > | bytes, |
|
|
const ProcessOptions & | options = {} ) |
Start with bytes delivered through a private inherited standard-input pipe.
Delivery is bounded and unrelated child handles are closed.
◆ start_with_standard_input_channel()
| bool pulp::platform::ChildProcess::start_with_standard_input_channel |
( |
const std::string & | command, |
|
|
const std::vector< std::string > & | args, |
|
|
const StandardInputChannelSession & | session, |
|
|
const ProcessOptions & | options = {} ) |
Spawn with a private duplex standard-input channel and transfer the parent endpoint to a post-spawn session.
Unsupported platforms fail before spawning. Session failure terminates and joins the child.
◆ wait()
Wait for the process to complete and return the result.
The documentation for this class was generated from the following file: