process-cpp
3.0.0
A simple convenience library for handling processes in C++11.
|
The DeathObserver class observes child process' states and emits a signal when a monitored child has died. More...
#include <child_process.h>
Public Member Functions | |
DeathObserver (const DeathObserver &)=delete | |
virtual | ~DeathObserver ()=default |
DeathObserver & | operator= (const DeathObserver &)=delete |
bool | operator== (const DeathObserver &) const =delete |
virtual bool | add (const ChildProcess &child)=0 |
add adds the specified child to the list of observed child processes. More... | |
virtual bool | has (const ChildProcess &child) const =0 |
has checks whether the specified child is observed. More... | |
virtual const core::Signal< ChildProcess > & | child_died () const =0 |
child_died is emitted whenever an observed child ceases to exist. More... | |
virtual void | on_sig_child ()=0 |
Checks and reaps all child processes registered with the observer instance. More... | |
Static Public Member Functions | |
static std::unique_ptr< DeathObserver > | create_once_with_signal_trap (std::shared_ptr< SignalTrap > trap) |
Creates the unique instance of class DeathObserver. More... | |
Protected Member Functions | |
DeathObserver ()=default | |
The DeathObserver class observes child process' states and emits a signal when a monitored child has died.
Please note that the name of this class is morbid for a reason: Listening for SIGCHLD is not enough to catch all dying children. Whenever a SIGCHLD is received, we have to wait for all the children of this process and reap all monitored ones. We are thus changing state and potentially race with other wait operations on children.
Definition at line 56 of file child_process.h.
|
delete |
|
virtualdefault |
|
protecteddefault |
|
pure virtual |
add adds the specified child to the list of observed child processes.
child | The child to be observed. |
|
pure virtual |
child_died is emitted whenever an observed child ceases to exist.
|
static |
Creates the unique instance of class DeathObserver.
std::logic_error | if the given SignalTrap instance does not trap Signal::sig_chld. |
std::runtime_error | if there already is an instance of the death observer. |
Definition at line 152 of file child_process.cpp.
|
pure virtual |
has checks whether the specified child is observed.
child | The child to check for. |
|
pure virtual |
Checks and reaps all child processes registered with the observer instance.
|
delete |
|
delete |