![]() |
Diana Software
|
process status and signal handler More...
Public Member Functions | |
| virtual | ~QProcessStatus () |
| dtor More... | |
| void | Associate (int signalId, ProcessStatus_t pStatus) |
| associate a signal to a given process status More... | |
| void | Disable (int signalId) |
| disable handling of a signal (use defauls system handler) More... | |
| bool | Ignore (int signalId) |
| ignore signal More... | |
| bool | HasChanged () const |
| tell wehter process status has changed More... | |
| ProcessStatus_t | GetState () const |
| get current state More... | |
| ProcessStatus_t | GetPreviousState () const |
| get previous state More... | |
| ProcessStatus_t | GetNextState () const |
| get the status the process will go into the next time that Notify() will be called. Returns current state if hasChanged() returns false More... | |
| void | SetState (ProcessStatus_t state) |
| change current process status bypassing status queue vector More... | |
| void | Notify () |
| acknowledge oldest process status contained in staus queue More... | |
| bool | isRunning () const |
| check wether current process status is QRunning_s More... | |
| bool | isPaused () const |
| check wether current process status is QPaused_s More... | |
| bool | isIdle () const |
| check wether current process status is QIdle_s More... | |
| bool | isReady () const |
| check wether current process status is QReady_s More... | |
| bool | isExiting () const |
| check wether current process status is QExiting_s More... | |
| bool | isWaiting () const |
| check wether current process status is QWaiting_s More... | |
| const std::string & | GetError () const |
| get error string More... | |
| void | SetError (const std::string &errMsg) |
| set error string More... | |
| bool | isError () const |
| check wether an error occurred More... | |
| bool | TrgCtrlEnabled () const |
| check wether trigger control signals are enabled More... | |
| void | SetTrgCtrlEnabled (bool enabled) |
| enable or disable trigger status control More... | |
| void | InformServer () |
| inform MsgServer about current process status More... | |
| void | SetName (const std::string &name) |
| set process name that will be used for communication with message logger server More... | |
| void | EnableInformServer (bool enabled) |
Public Member Functions inherited from QNamed | |
| QNamed () | |
| QNamed (const std::string &Name) | |
| virtual | ~QNamed () |
| const std::string & | GetName () const |
| void | SetName (const std::string &name) |
Static Public Member Functions | |
| static QProcessStatus & | GetInstance () |
| get singleton Instance More... | |
Private Member Functions | |
| QProcessStatus () | |
| ctor More... | |
| void | HandleSignal (int signalId) |
| this method is called each time a registered signal is caught. It updates the status queue and inform message logger if necessary. More... | |
| void | AddToQueue (ProcessStatus_t state) |
| add state to process status queue. More... | |
| ProcessStatus_t | GetLastStatus () const |
| get last status that have been added to status queue. If queue is empty current process status is returned. More... | |
Private Member Functions inherited from QId | |
| QId () | |
| QId (int id) | |
| virtual | ~QId () |
| void | SetId (int id) |
| int | GetId () const |
Private Attributes | |
| ProcessStatus_t | fState |
| current process status More... | |
| ProcessStatus_t | fPreviousState |
| previous process status More... | |
| bool | fTrgCtrl |
| bool | fInformEnabled |
| const size_t | kMaxQueued |
| std::deque< ProcessStatus_t > | fStatusQueue |
| std::string | fError |
| error string More... | |
| std::map< int, ProcessStatus_t > | fSigMap |
Friends | |
| void | SigHandler (int) |
| signal handler function More... | |
process status and signal handler
Each signal can be associated to a value of ProcessStatus_t. More than one signal can be associated to the same process status.
By default no signal is handled.
When a signal is not enabled, the default signal handler is called.
In order for a signal to be ignored, the Ignore() method must be called with the signal as argument.
The behavior for SIGFPE and SIGSEGV is different from that of other signals: if the handling of these signals is enabled, they are automatically associated to QError_s state. Moreover these signals cannot be ignored.
Definition at line 31 of file QProcessStatus.hh.
|
inlinevirtual |
dtor
Definition at line 38 of file QProcessStatus.hh.
|
private |
|
private |
add state to process status queue.
| state | status to be added to queue |
If state is QTriggerOn_s or QTriggerOff_s, the queue is populated with 2 new elements: the requested state and then the current one. If process queue has more than kMaxQueued elements a warning is sent to stderr.
Definition at line 258 of file QProcessStatus.cc.
References fStatusQueue, GetLastStatus(), kMaxQueued, QTriggerOff_s, and QTriggerOn_s.
Referenced by HandleSignal(), and SigHandler().
| void QProcessStatus::Associate | ( | int | signalId, |
| ProcessStatus_t | pStatus | ||
| ) |
associate a signal to a given process status
If signalId is SIGSEGV or SIGFPE, pStatus is ignored, and signal is associated to QError_s
Definition at line 57 of file QProcessStatus.cc.
References fSigMap, QError_s, and SigHandler.
Referenced by main().
| void QProcessStatus::Disable | ( | int | signalId | ) |
disable handling of a signal (use defauls system handler)
Definition at line 37 of file QProcessStatus.cc.
References fSigMap.
|
inline |
Definition at line 117 of file QProcessStatus.hh.
References fInformEnabled.
|
inline |
get error string
Definition at line 91 of file QProcessStatus.hh.
References fError.
Referenced by QSequence::Run().
|
static |
get singleton Instance
Definition at line 12 of file QProcessStatus.cc.
Referenced by main(), QFrameWork::Run(), and QSequence::Run().
|
private |
get last status that have been added to status queue. If queue is empty current process status is returned.
Definition at line 278 of file QProcessStatus.cc.
References fState, and fStatusQueue.
Referenced by AddToQueue(), and HandleSignal().
|
inline |
get the status the process will go into the next time that Notify() will be called. Returns current state if hasChanged() returns false
Definition at line 64 of file QProcessStatus.hh.
References fState, fStatusQueue, and HasChanged().
|
inline |
|
inline |
|
private |
this method is called each time a registered signal is caught. It updates the status queue and inform message logger if necessary.
| signalId | system signal to be handled |
Add status associated to signal signalId to process status queue. If signal is SIGSEGV or SIGFPE and process queue already contains another error, exit is forced calling exit(1). Detected signal is added to queue only if it is consistent with last status that is in queue (or with current status in case queue is empty). In case of inconistent state, an error is set by mean of SetError(). For example stop signal is not considered if process is not running.
Definition at line 68 of file QProcessStatus.cc.
References AddToQueue(), fSigMap, fStatusQueue, GetLastStatus(), InformServer(), QAskStatus_s, QError_s, QExiting_s, QIdle_s, QPaused_s, QReady_s, QRunning_s, QStopped_s, QWaiting_s, and SetError().
|
inline |
tell wehter process status has changed
Definition at line 53 of file QProcessStatus.hh.
References fStatusQueue.
Referenced by GetNextState(), QFrameWork::Run(), and QSequence::Run().
| bool QProcessStatus::Ignore | ( | int | signalId | ) |
| void QProcessStatus::InformServer | ( | ) |
inform MsgServer about current process status
Msg Server is informed by mean of a socket client. If error string is not empty, it is sent to Daq Server together with process status Id.
Definition at line 213 of file QProcessStatus.cc.
References err, fInformEnabled, and QERR_SUCCESS.
Referenced by HandleSignal(), Notify(), and SetState().
|
inline |
check wether an error occurred
Definition at line 95 of file QProcessStatus.hh.
References fError.
Referenced by QSequence::Run().
|
inline |
check wether current process status is QExiting_s
Definition at line 86 of file QProcessStatus.hh.
References fState, and QExiting_s.
Referenced by QSequence::Run().
|
inline |
check wether current process status is QIdle_s
Definition at line 82 of file QProcessStatus.hh.
|
inline |
check wether current process status is QPaused_s
Definition at line 80 of file QProcessStatus.hh.
|
inline |
check wether current process status is QReady_s
Definition at line 84 of file QProcessStatus.hh.
|
inline |
check wether current process status is QRunning_s
Definition at line 78 of file QProcessStatus.hh.
References fState, and QRunning_s.
Referenced by QFrameWork::Run(), and QSequence::Run().
|
inline |
check wether current process status is QWaiting_s
Definition at line 88 of file QProcessStatus.hh.
References fState, and QWaiting_s.
| void QProcessStatus::Notify | ( | ) |
acknowledge oldest process status contained in staus queue
Definition at line 243 of file QProcessStatus.cc.
References fPreviousState, fState, fStatusQueue, and InformServer().
Referenced by QFrameWork::Run(), and QSequence::Run().
|
inline |
set error string
Definition at line 93 of file QProcessStatus.hh.
References fError.
Referenced by HandleSignal(), and SigHandler().
|
inline |
set process name that will be used for communication with message logger server
| name | process name |
Definition at line 115 of file QProcessStatus.hh.
References QNamed::SetName().
| void QProcessStatus::SetState | ( | ProcessStatus_t | state | ) |
change current process status bypassing status queue vector
| state | new process status |
Previous state is updated, status queue is flushed and InformServer() is called
Definition at line 227 of file QProcessStatus.cc.
References ProcessStatus_t::AsString(), fPreviousState, fState, fStatusQueue, and InformServer().
Referenced by main().
|
inline |
enable or disable trigger status control
Definition at line 100 of file QProcessStatus.hh.
References fTrgCtrl.
|
inline |
check wether trigger control signals are enabled
Definition at line 98 of file QProcessStatus.hh.
References fTrgCtrl.
|
friend |
signal handler function
| signalId | signal to be handled |
When a registered system signal is detected, this function simply calls the QProcessStatus::HandleSignal() method.
Definition at line 287 of file QProcessStatus.cc.
Referenced by Associate().
|
private |
error string
Definition at line 135 of file QProcessStatus.hh.
Referenced by GetError(), isError(), and SetError().
|
private |
wether to inform server about state changes
Definition at line 129 of file QProcessStatus.hh.
Referenced by EnableInformServer(), and InformServer().
|
private |
previous process status
Definition at line 125 of file QProcessStatus.hh.
Referenced by GetPreviousState(), Notify(), and SetState().
|
private |
key: system signal
Definition at line 137 of file QProcessStatus.hh.
Referenced by Associate(), Disable(), HandleSignal(), Ignore(), and QProcessStatus().
|
private |
current process status
Definition at line 123 of file QProcessStatus.hh.
Referenced by GetLastStatus(), GetNextState(), GetState(), isExiting(), isIdle(), isPaused(), isReady(), isRunning(), isWaiting(), Notify(), and SetState().
|
private |
contains stauts evolution for current process
Definition at line 133 of file QProcessStatus.hh.
Referenced by AddToQueue(), GetLastStatus(), GetNextState(), HandleSignal(), HasChanged(), Notify(), QProcessStatus(), and SetState().
|
private |
wether trigger control signals are enabled
Definition at line 127 of file QProcessStatus.hh.
Referenced by SetTrgCtrlEnabled(), and TrgCtrlEnabled().
|
private |
max number of not-notified process states
Definition at line 131 of file QProcessStatus.hh.
Referenced by AddToQueue().