Process handle. More...
#include "handle-misc.hpp"
Public Types | |
using | uv_t = ::uv_process_t |
using | on_exit_t = std::function< void(process _handle, int64_t _exit_status, int _termination_signal) > |
The function type of the callback called when the child process exits. More... | |
Public Types inherited from uv::handle | |
using | uv_t = ::uv_handle_t |
using | on_destroy_t = std::function< void(void *_data) > |
The function type of the callback called when the handle has been closed and about to be destroyed. More... | |
Public Member Functions | |
process (const process &)=default | |
process & | operator= (const process &)=default |
process (process &&) noexcept=default | |
process & | operator= (process &&) noexcept=default |
process (uv::loop &_loop) | |
Create a process handle. | |
int | pid () const noexcept |
The PID of the child process. It is set after calling spawn() . | |
int | spawn (const char *_file, char *_argv[], ::uv_process_flags _flags=static_cast< ::uv_process_flags >(0)) const noexcept |
Create and start a new child process. More... | |
int | spawn (const char *_file, const char *_argv[], ::uv_process_flags _flags=static_cast< ::uv_process_flags >(0)) const noexcept |
int | kill (int _signum) const noexcept |
Send the specified signal to the child process. | |
operator const uv_t * () const noexcept | |
operator uv_t * () noexcept | |
Functions to prepare for spawning a child process:: | |
on_exit_t & | on_exit () const noexcept |
Set the callback function called when the child process exits. | |
void | set_environment (char *_envp[]) const noexcept |
Set pointer to environment for the child process. If nullptr the parents environment is used. | |
void | set_working_dir (const char *_cwd) const noexcept |
Set current working directory when spawning the child process. | |
void | inherit_stdio (unsigned _target_fd_number, io _io) const |
Set the io endpoint that should be available to the child process as the target stdio file descriptor number. More... | |
void | inherit_stdio (unsigned _target_fd_number, ::uv_file _fd) const |
Set the file descriptor that should be inherited by the child process as the target stdio descriptor number. | |
int | create_stdio_pipe (unsigned _target_fd_number, uv::loop &_pipe_loop, ::uv_stdio_flags _pipe_flags, bool _ipc=false) const |
Create a pipe to the child process' stdio fd number. More... | |
std::vector< io > & | stdio () const noexcept |
The stdio endpoints to be set for the child process. | |
void | set_uid (::uv_uid_t _uid) const noexcept |
Set the child process' user id. More... | |
void | set_gid (::uv_gid_t _gid) const noexcept |
Set the child process' group id. More... | |
Public Member Functions inherited from uv::handle | |
handle (const handle &_that) | |
handle & | operator= (const handle &_that) |
handle (handle &&_that) noexcept | |
handle & | operator= (handle &&_that) noexcept |
void | swap (handle &_that) noexcept |
std::uintptr_t | id () const noexcept |
The unique ID of the instance managed by this handle variable or 0 if the handle is void. | |
long | nrefs () const noexcept |
The current number of existing references to the same object as this handle variable refers to. | |
int | uv_status () const noexcept |
The status value returned by the last executed libuv API function on this handle. | |
on_destroy_t & | on_destroy () const noexcept |
::uv_handle_type | type () const noexcept |
The tag indicating the libuv type of the handle. | |
const char * | type_name () const noexcept |
A string containing the name of the handle type. | |
uv::loop | loop () const noexcept |
The libuv loop where the handle is running on. More... | |
void *& | data () const noexcept |
The pointer to the user-defined arbitrary data. libuv and uvcc does not use this field. | |
int | is_active () const noexcept |
Check if the handle is active. More... | |
int | is_closing () const noexcept |
Check if the handle is closing or closed. More... | |
::uv_os_fd_t | fileno () const noexcept |
Get the platform dependent handle/file descriptor. More... | |
operator const uv_t * () const noexcept | |
operator uv_t * () noexcept | |
operator bool () const noexcept | |
Equivalent to (id() and uv_status() >= 0) . | |
void | attached (bool _state) const noexcept |
bool | attached () const noexcept |
Static Public Member Functions | |
static void | disable_stdio_inheritance () noexcept |
Force child processes spawned by this process not to inherit file descriptors/handles that this process has inherited from its parent. More... | |
static int | kill (int _pid, int _signum) noexcept |
Send the specified signal to the given PID. More... | |
Process handle.
uv_process_t
— Process handle. Definition at line 1251 of file handle-misc.hpp.
using uv::process::on_exit_t = std::function< void(process _handle, int64_t _exit_status, int _termination_signal) > |
The function type of the callback called when the child process exits.
uv_exit_cb
. Definition at line 1262 of file handle-misc.hpp.
|
inlinestaticnoexcept |
Force child processes spawned by this process not to inherit file descriptors/handles that this process has inherited from its parent.
uv_disable_stdio_inheritance()
. Definition at line 1343 of file handle-misc.hpp.
|
inlinestaticnoexcept |
Send the specified signal to the given PID.
uv_kill()
. Definition at line 1347 of file handle-misc.hpp.
|
inline |
Set the io endpoint that should be available to the child process as the target stdio file descriptor number.
uv_process_options_t.stdio
, uv_process_options_t
, uv_stdio_container_t
, uv_stdio_flags
. Definition at line 1377 of file handle-misc.hpp.
|
inline |
Create a pipe to the child process' stdio fd number.
Only UV_READABLE_PIPE
and UV_WRITABLE_PIPE
flags from the uv_stdio_flags
enumeration take effect.
Set _ipc
parameter to true
if the created pipe is going to be used for handle passing between processes.
uv_stdio_flags
, uv_process_options_t.stdio
. Definition at line 1421 of file handle-misc.hpp.
|
inlinenoexcept |
Set the child process' user id.
Specifying a value of -1 clears the UV_PROCESS_SETUID
flag.
uv_process_options_t.uid
, uv_process_flags
, Definition at line 1452 of file handle-misc.hpp.
|
inlinenoexcept |
Set the child process' group id.
Specifying a value of -1 clears the UV_PROCESS_SETGID
flag.
uv_process_options_t.gid
, uv_process_flags
, Definition at line 1468 of file handle-misc.hpp.
|
inlinenoexcept |
Create and start a new child process.
uv_spawn()
, uv_process_flags
. Definition at line 1485 of file handle-misc.hpp.