ui-utilcpp
1.8.5
|
Simple encapsulation for any process based threading system. More...
#include <Thread.hpp>
Public Types | |
enum | ReservedStatus { NotRunYet_ = 255, Running_ = 254, WaitpidErr_ = 253, KilledByUncatchedSignal_ = 252 } |
Reserved exit status'. Do not use these as return codes in your run()-functions. More... | |
Public Member Functions | |
virtual void | start ()=0 |
Start fork "thread". | |
bool | isRunning () |
pid_t | getPID () const |
Get PID of running "thread". | |
int | wait () |
Wait for this "thread", and return the process' exit status. More... | |
int | getStatus () const |
Get status of last run. | |
Protected Member Functions | |
virtual int | run ()=0 |
Protected Attributes | |
pid_t | pid_ |
int | status_ |
Simple encapsulation for any process based threading system.
You need to overload "start" and "run".
Reserved exit status'. Do not use these as return codes in your run()-functions.
Program exit status' are always between (including) 0..255; to be able to use the exit status directly in programs (e.g. for std::exit()), we reserve some values here (rather than using out-of-range values).
bool UI::Util::ProcessThread::isRunning | ( | ) |
Check if "thread" is running.
References status_.
|
protectedpure virtual |
Virtual function of thread's task.
Referenced by UI::Util::ForkThread::start().
int UI::Util::ProcessThread::wait | ( | ) |
Wait for this "thread", and return the process' exit status.
You must use this method to avoid zombies, or ignore all SIGCHLDs in the parent.
References status_.
Referenced by getPID().
|
protected |
Process id of thread: Must be set properly by overloaded start method.
Referenced by getPID(), and UI::Util::ForkThread::start().
|
protected |
Status of thread: Must be set properly by overloaded start method.
Referenced by getPID(), getStatus(), isRunning(), UI::Util::ForkThread::start(), and wait().