process-cpp
3.0.0
A simple convenience library for handling processes in C++11.
|
The Process class models a child process of this process. More...
#include <child_process.h>
Classes | |
class | DeathObserver |
The DeathObserver class observes child process' states and emits a signal when a monitored child has died. More... | |
struct | Private |
Public Member Functions | |
~ChildProcess () | |
wait::Result | wait_for (const wait::Flags &flags) |
Wait for the child process to change state. More... | |
std::istream & | cerr () |
Access this process's stderr. More... | |
std::ostream & | cin () |
Access this process's stdin. More... | |
std::istream & | cout () |
Access this process's stdout. More... | |
![]() | |
Process (pid_t pid) | |
Creates a process instance wrapping an existing process. More... | |
virtual | ~Process () noexcept |
Frees resources associated with the process. More... | |
virtual pid_t | pid () const |
Query the pid of the process. More... | |
virtual ProcessGroup | process_group_or_throw () const |
Queries the id of the process group this process belongs to. More... | |
virtual ProcessGroup | process_group (std::error_code &se) const noexcept(true) |
Queries the id of the process group this process belongs to. More... | |
![]() | |
virtual void | send_signal_or_throw (Signal signal) |
Sends a signal to this signalable object. More... | |
virtual void | send_signal (Signal signal, std::error_code &e) noexcept(true) |
Sends a signal to this signalable object. More... | |
Static Public Member Functions | |
static ChildProcess | invalid () |
Creates an invalid ChildProcess. More... | |
![]() | |
static Process | invalid () |
Returns an invalid instance for testing purposes. More... | |
Friends | |
ChildProcess | fork (const std::function< posix::exit::Status()> &, const StandardStream &) |
fork forks a new process and executes the provided main function in the newly forked process. More... | |
ChildProcess | vfork (const std::function< posix::exit::Status()> &, const StandardStream &) |
fork vforks a new process and executes the provided main function in the newly forked process. More... | |
Additional Inherited Members | |
![]() | |
CORE_POSIX_DLL_LOCAL | Signalable (pid_t pid) |
The Process class models a child process of this process.
In addition to the functionality offered by the Process class, an instance of ChildProcess offers functionality to wait for status changes of the child process and to access the child process's standard streams if they have been redirected when forking or exec'ing.
Definition at line 43 of file child_process.h.
core::posix::ChildProcess::~ChildProcess | ( | ) |
Definition at line 341 of file child_process.cpp.
std::istream & core::posix::ChildProcess::cerr | ( | ) |
Access this process's stderr.
Definition at line 382 of file child_process.cpp.
Referenced by TEST().
std::ostream & core::posix::ChildProcess::cin | ( | ) |
Access this process's stdin.
Definition at line 387 of file child_process.cpp.
Referenced by TEST().
std::istream & core::posix::ChildProcess::cout | ( | ) |
Access this process's stdout.
Definition at line 392 of file child_process.cpp.
Referenced by TEST().
|
static |
Creates an invalid ChildProcess.
Definition at line 325 of file child_process.cpp.
wait::Result core::posix::ChildProcess::wait_for | ( | const wait::Flags & | flags | ) |
Wait for the child process to change state.
[in] | flags | Alters the behavior of the wait operation. |
Definition at line 345 of file child_process.cpp.
References core::posix::wait::Result::detail, core::posix::wait::Result::if_exited, core::posix::wait::Result::if_signaled, core::posix::wait::Result::if_stopped, and core::posix::wait::Result::status.
|
friend |
fork forks a new process and executes the provided main function in the newly forked process.
std::system_error | in case of errors. |
[in] | main | The main function of the newly forked process. |
[in] | flags | Specify which standard streams should be redirected to the parent process. |
|
friend |
fork vforks a new process and executes the provided main function in the newly forked process.
std::system_error | in case of errors. |
[in] | main | The main function of the newly forked process. |
[in] | flags | Specify which standard streams should be redirected to the parent process. |