Process
#include <icy/process.h>
class ProcessDefined in src/base/include/icy/process.h:32
Public Attributes
| Return | Name | Description |
|---|---|---|
std::string | file | Path to the program to execute. Convenience proxy for options.file. Must be set before spawn() |
std::string | cwd | Set the current working directory. Convenience proxy for options.cwd. Must be set before spawn() |
std::vector< std::string > | args | Command line arguments to pass to the process. Convenience proxy for options.args. Must be set before 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() |
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. |
file
std::string fileDefined in src/base/include/icy/process.h:55
Path to the program to execute. Convenience proxy for options.file. Must be set before spawn()
cwd
std::string cwdDefined in src/base/include/icy/process.h:60
Set the current working directory. Convenience proxy for options.cwd. Must be set before spawn()
args
std::vector< std::string > argsDefined in src/base/include/icy/process.h:65
Command line arguments to pass to the process. Convenience proxy for options.args. Must be set before spawn()
env
std::vector< std::string > envDefined in src/base/include/icy/process.h:71
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()
onstdout
std::function< void(std::string)> onstdoutDefined in src/base/include/icy/process.h:97
Stdout callback. Called when a line has been output from the process.
onstderr
std::function< void(std::string)> onstderrDefined in src/base/include/icy/process.h:101
Stderr callback. Called when a line has been output on stderr.
onexit
std::function< void(std::int64_t)> onexitDefined in src/base/include/icy/process.h:105
Exit callback. Called with process exit status code.
options
ProcessOptions optionsType: ProcessOptions
Defined in src/base/include/icy/process.h:109
LibUV C options. Available for advanced use cases.
Public Methods
| Return | Name | Description |
|---|---|---|
Process | Constructs a Process attached to the given event loop. | |
Process | Constructs a Process with initial command-line arguments. | |
~Process | Destructor. | |
Process | Deleted constructor. | |
Process & | operator= | Deleted assignment operator. |
Process | Deleted constructor. | |
Process & | operator= | Deleted assignment operator. |
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
Process(uv::Loop * loop = uv::defaultLoop())Defined in src/base/include/icy/process.h:37
Constructs a Process attached to the given event loop.
Parameters
| Parameter | Type | Description |
|---|---|---|
loop | uv::Loop * | Event loop to use for I/O and exit notifications. Defaults to the default loop. |
Process
Process(std::initializer_list< std::string > args, uv::Loop * loop = uv::defaultLoop())Defined in src/base/include/icy/process.h:42
Constructs a Process with initial command-line arguments.
Parameters
| Parameter | Type | Description |
|---|---|---|
args | std::initializer_list< std::string > | Initializer list of argument strings. The first element is typically the executable path. |
loop | uv::Loop * | Event loop to use for I/O and exit notifications. Defaults to the default loop. |
~Process
~Process()Defined in src/base/include/icy/process.h:45
Destructor.
Process
Process(const Process &) = deleteDefined in src/base/include/icy/process.h:47
Deleted constructor.
operator=
Process & operator=(const Process &) = deleteDefined in src/base/include/icy/process.h:48
Deleted assignment operator.
Process
Process(Process &&) = deleteDefined in src/base/include/icy/process.h:49
Deleted constructor.
operator=
Process & operator=(Process &&) = deleteDefined in src/base/include/icy/process.h:50
Deleted assignment operator.
spawn
void spawn()Defined in src/base/include/icy/process.h:76
Spawns the process. Options must be properly set. Throws an exception on error.
kill
bool kill(int signum = SIGTERM)Defined in src/base/include/icy/process.h:81
Sends a signal to the process.
Returns
True if the signal was sent successfully, false if the process is not running or handle is invalid.
Parameters
| Parameter | Type | Description |
|---|---|---|
signum | int | Signal number to send (default: SIGTERM). |
pid
const
int pid() constDefined in src/base/include/icy/process.h:84
Returns the process PID, or 0 if not spawned.
in
Pipe & in()Defined in src/base/include/icy/process.h:87
Returns the stdin pipe.
out
Pipe & out()Defined in src/base/include/icy/process.h:90
Returns the stdout pipe.
err
Pipe & err()Defined in src/base/include/icy/process.h:93
Returns the stderr pipe.
Protected Attributes
| 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 |
_handle
uv::Handle< uv_process_t > _handleType: uv::Handle< uv_process_t >
Defined in src/base/include/icy/process.h:114
_stdin
Pipe _stdinType: Pipe
Defined in src/base/include/icy/process.h:115
_stdout
Pipe _stdoutType: Pipe
Defined in src/base/include/icy/process.h:116
_stderr
Pipe _stderrType: Pipe
Defined in src/base/include/icy/process.h:117
_stdio
uv_stdio_container_t _stdio[3]Defined in src/base/include/icy/process.h:118
_cargs
std::vector< char * > _cargsDefined in src/base/include/icy/process.h:119
_cenv
std::vector< char * > _cenvDefined in src/base/include/icy/process.h:120
Protected Methods
| Return | Name | Description |
|---|---|---|
void | init |
init
void init()