#include <icy/process.h>Spawns and manages a child process with stdin/stdout/stderr pipes.
| Return | Name | Description |
|---|---|---|
std::string | file | Path to the program to execute. Convenience proxy for options.file. Must be set before [spawn()](#spawn) |
std::string | cwd | Set the current working directory. Convenience proxy for options.cwd. Must be set before [spawn()](#spawn) |
std::vector< std::string > | args | Command line arguments to pass to the process. Convenience proxy for options.args. Must be set before [spawn()](#spawn) |
std::vector< std::string > | env | Environment variables for the process. Each entry should be in "KEY=VALUE" format. If empty, the child inherits the parent environment. Must be set before [spawn()](#spawn) |
std::function< void(std::string)> | onstdout | Stdout callback. Called when a line has been output from the process. |
std::function< void(std::string)> | onstderr | Stderr callback. Called when a line has been output on stderr. |
std::function< void(std::int64_t)> | onexit | Exit callback. Called with process exit status code. |
ProcessOptions | options | LibUV C options. Available for advanced use cases. |
std::string filePath to the program to execute. Convenience proxy for options.file. Must be set before [spawn()](#spawn)
std::string cwdSet the current working directory. Convenience proxy for options.cwd. Must be set before [spawn()](#spawn)
std::vector< std::string > argsCommand line arguments to pass to the process. Convenience proxy for options.args. Must be set before [spawn()](#spawn)
std::vector< std::string > envEnvironment variables for the process. Each entry should be in "KEY=VALUE" format. If empty, the child inherits the parent environment. Must be set before [spawn()](#spawn)
std::function< void(std::string)> onstdoutStdout callback. Called when a line has been output from the process.
std::function< void(std::string)> onstderrStderr callback. Called when a line has been output on stderr.
std::function< void(std::int64_t)> onexitExit callback. Called with process exit status code.
ProcessOptions optionsLibUV C options. Available for advanced use cases.
| Return | Name | Description |
|---|---|---|
Process | Constructs a [Process](#process-4) attached to the given event loop. | |
Process | Constructs a [Process](#process-4) with initial command-line arguments. | |
~Process | Destructor. | |
Process | Deleted constructor. | |
Process | Deleted constructor. | |
void | spawn | Spawns the process. Options must be properly set. Throws an exception on error. |
bool | kill | Sends a signal to the process. |
int | pid const | Returns the process PID, or 0 if not spawned. |
Pipe & | in | Returns the stdin pipe. |
Pipe & | out | Returns the stdout pipe. |
Pipe & | err | Returns the stderr pipe. |
Process(uv::Loop * loop)Constructs a [Process](#process-4) attached to the given event loop.
loop Event loop to use for I/O and exit notifications. Defaults to the default loop.Process(std::initializer_list< std::string > args, uv::Loop * loop)Constructs a [Process](#process-4) with initial command-line arguments.
args Initializer list of argument strings. The first element is typically the executable path.
loop Event loop to use for I/O and exit notifications. Defaults to the default loop.
~Process()Destructor.
Process(const Process &) = deleteDeleted constructor.
Process(Process &&) = deleteDeleted constructor.
void spawn()Spawns the process. Options must be properly set. Throws an exception on error.
bool kill(int signum)Sends a signal to the process.
signum Signal number to send (default: SIGTERM).True if the signal was sent successfully, false if the process is not running or handle is invalid.
const
int pid() constReturns the process PID, or 0 if not spawned.
Pipe & in()Returns the stdin pipe.
Pipe & out()Returns the stdout pipe.
Pipe & err()Returns the stderr pipe.
| Return | Name | Description |
|---|---|---|
uv::Handle< uv_process_t > | _handle | |
Pipe | _stdin | |
Pipe | _stdout | |
Pipe | _stderr | |
uv_stdio_container_t | _stdio | |
std::vector< char * > | _cargs | |
std::vector< char * > | _cenv |
uv::Handle< uv_process_t > _handlePipe _stdinPipe _stdoutPipe _stderruv_stdio_container_t _stdiostd::vector< char * > _cargsstd::vector< char * > _cenv| Return | Name | Description |
|---|---|---|
void | init |
void init()