|
blocxx
|
Class for communicating with and managing a child process. More...
#include <Process.hpp>
Classes | |
| class | Status |
| Portable process status. More... | |
Public Types | |
| enum | ETerminationSelectionFlag { E_TERMINATE_PROCESS_GROUP, E_TERMINATE_PROCESS_ONLY } |
Public Member Functions | |
| Process (UnnamedPipeRef const &in, UnnamedPipeRef const &out, UnnamedPipeRef const &err, ProcId pid) | |
| Process (ProcId pid) | |
| void | release () |
| Releases ownership of the ProcId and UnnamedPipes held by this object. More... | |
| virtual | ~Process () |
If release has been called on this object, does nothing. More... | |
| UnnamedPipeRef | in () const |
| Stdin for the child process. More... | |
| UnnamedPipeRef | out () const |
| Stdout for the child process. More... | |
| UnnamedPipeRef | err () const |
| Stderr for the child process. More... | |
| ProcId | pid () const |
| Process ID for the child process. More... | |
| Status | processStatus () |
| void | waitCloseTerm (const Timeout &wait_initial=Timeout::relative(5.0), const Timeout &wait_close=Timeout::relative(10.0), const Timeout &wait_term=Timeout::relative(15.0), ETerminationSelectionFlag terminationSelectionFlag=E_TERMINATE_PROCESS_GROUP) |
| Waits for the child process to terminate, taking increasingly severe measures to ensure that this happens. More... | |
| void | waitCloseTerm (float wait_initial, float wait_close, float wait_term) |
| Waits for the child process to terminate, taking increasingly severe measures to ensure that this happens. More... | |
Protected Member Functions | |
| Process (const ProcessImplRef &impl, UnnamedPipeRef const &in, UnnamedPipeRef const &out, UnnamedPipeRef const &err, ProcId pid) | |
| Constructor for derived classes that allow them to override the implementation. More... | |
Protected Member Functions inherited from BLOCXX_NAMESPACE::IntrusiveCountableBase | |
| IntrusiveCountableBase () | |
| IntrusiveCountableBase (const IntrusiveCountableBase &) | |
| IntrusiveCountableBase & | operator= (const IntrusiveCountableBase &) |
| virtual | ~IntrusiveCountableBase () |
Private Member Functions | |
| bool | terminatesWithin (const Timeout &wait_time) |
| ProcId | getCurProcessId () |
| bool | killWait (const Timeout &wait_time, int sig, char const *signame, ETerminationSelectionFlag terminationSelectionFlag) |
| Process (Process const &) | |
| Copying not allowed (private) More... | |
| void | operator= (Process const &) |
| Assignment not allowed (private) More... | |
Private Attributes | |
| ProcessImplRef | m_impl |
| UnnamedPipeRef | m_in |
| UnnamedPipeRef | m_out |
| UnnamedPipeRef | m_err |
| ProcId | m_pid |
| Status | m_status |
Class for communicating with and managing a child process.
Definition at line 91 of file Process.hpp.
| Enumerator | |
|---|---|
| E_TERMINATE_PROCESS_GROUP | The process and any descendent processes which are in the process group will be terminated. |
| E_TERMINATE_PROCESS_ONLY | The process will be terminated. |
Definition at line 239 of file Process.hpp.
| BLOCXX_NAMESPACE::Process::Process | ( | UnnamedPipeRef const & | in, |
| UnnamedPipeRef const & | out, | ||
| UnnamedPipeRef const & | err, | ||
| ProcId | pid | ||
| ) |
Definition at line 356 of file Process.cpp.
|
protected |
Constructor for derived classes that allow them to override the implementation.
This is necessary because destructors shouldn't call virtual functions (it's undefined behavior), so instead of this class having virtual functions, that is moved to ProcessImpl.
Definition at line 369 of file Process.cpp.
References BLOCXX_NAMESPACE::Timeout::relative(), and waitCloseTerm().
| BLOCXX_NAMESPACE::Process::Process | ( | ProcId | pid | ) |
Definition at line 383 of file Process.cpp.
References BLOCXX_LOG_DEBUG, BLOCXX_NAMESPACE::FileSystem::COMPONENT_NAME, m_impl, m_pid, m_status, and BLOCXX_NAMESPACE::Process::Status::terminated().
|
virtual |
If release has been called on this object, does nothing.
Otherwise, closes pipes and waits for process to die, killing it if necessary,
Definition at line 393 of file Process.cpp.
|
private |
Copying not allowed (private)
| UnnamedPipeRef BLOCXX_NAMESPACE::Process::err | ( | ) | const |
Stderr for the child process.
The default timeout is set to 10 minutes.
Definition at line 444 of file Process.cpp.
References BLOCXX_NAMESPACE::Timeout::relative(), and waitCloseTerm().
|
private |
Definition at line 713 of file Process.cpp.
| UnnamedPipeRef BLOCXX_NAMESPACE::Process::in | ( | ) | const |
Stdin for the child process.
The default timeout is set to 10 minutes.
Definition at line 434 of file Process.cpp.
|
private |
Definition at line 691 of file Process.cpp.
|
private |
Assignment not allowed (private)
| UnnamedPipeRef BLOCXX_NAMESPACE::Process::out | ( | ) | const |
Stdout for the child process.
The default timeout is set to 10 minutes.
Definition at line 439 of file Process.cpp.
| ProcId BLOCXX_NAMESPACE::Process::pid | ( | ) | const |
Process ID for the child process.
Definition at line 449 of file Process.cpp.
References m_pid.
Referenced by BLOCXX_NAMESPACE::Process::Status::toString().
| Process::Status BLOCXX_NAMESPACE::Process::processStatus | ( | ) |
| ProcessErrorException |
Definition at line 454 of file Process.cpp.
| void BLOCXX_NAMESPACE::Process::release | ( | ) |
Releases ownership of the ProcId and UnnamedPipes held by this object.
in(), out(), and err() are all null; pid() < 0; the dtor does nothing. Only the above-mentioned methods may be called on this object. Definition at line 426 of file Process.cpp.
References m_impl, m_pid, m_status, and BLOCXX_NAMESPACE::ProcessImpl::pollStatus().
|
private |
Definition at line 561 of file Process.cpp.
| void BLOCXX_NAMESPACE::Process::waitCloseTerm | ( | const Timeout & | wait_initial = Timeout::relative(5.0), |
| const Timeout & | wait_close = Timeout::relative(10.0), |
||
| const Timeout & | wait_term = Timeout::relative(15.0), |
||
| ETerminationSelectionFlag | terminationSelectionFlag = E_TERMINATE_PROCESS_GROUP |
||
| ) |
Waits for the child process to terminate, taking increasingly severe measures to ensure that this happens.
All timeouts are measured from the start of the function. The following steps are taken in order until termination is detected:
SIGTERM signal and waits until wait_term expires for it to die.SIGKILL signal.In steps 1-3 the function returns as soon as termination is detected. If this function is called a second time it is a no-op, because it immediately sees that the process has already terminated.
SIGTERM signal is sent.| ProcessErrorException |
Definition at line 480 of file Process.cpp.
| void BLOCXX_NAMESPACE::Process::waitCloseTerm | ( | float | wait_initial, |
| float | wait_close, | ||
| float | wait_term | ||
| ) |
Waits for the child process to terminate, taking increasingly severe measures to ensure that this happens.
All times are measured from the start of the function. The following steps are taken in order until termination is detected:
SIGTERM signal and waits until wait_term seconds have passed for it to die.SIGKILL signal.In steps 1-3 the function returns as soon as termination is detected. If this function is called a second time it is a no-op, because it immediately sees that the process has already terminated.
SIGTERM signal is sent.| ProcessErrorException |
Definition at line 475 of file Process.cpp.
|
private |
Definition at line 318 of file Process.hpp.
|
private |
Definition at line 315 of file Process.hpp.
|
private |
Definition at line 316 of file Process.hpp.
|
private |
Definition at line 317 of file Process.hpp.
|
private |
Definition at line 319 of file Process.hpp.
|
private |
Definition at line 320 of file Process.hpp.
Referenced by BLOCXX_NAMESPACE::Process::Status::exitStatus(), BLOCXX_NAMESPACE::Process::Status::exitTerminated(), Process(), release(), BLOCXX_NAMESPACE::Process::Status::running(), BLOCXX_NAMESPACE::Process::Status::Status(), and BLOCXX_NAMESPACE::Process::Status::terminated().
1.8.18