update process status according to received signal
Handled signals are: SIGINT, SIGABRT, SIGFPE, SIGSEGV, SIGTERM, SIGUSR1, SIGUSR2, SIGTTIN, SIGTTOU. Each signal can be associated to a value of ProcessStatus_t. More than one signal can be associated to the same process status. Several signals are enabled by default and serveral are not. Moreover, the association between a signal and the corresponding ProcessStatus_t is not modifiable for all signals, as for the enabled/disabled state, which can be toggled only for several signals. 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. All signals that can be disabled can be also ignored. Follows a detailed list of the possibilities the user has to control each signal:
Public Member Functions | |
| virtual | ~QProcessStatus () |
| dtor | |
| bool | Associate (int signalId, ProcessStatus_t pStatus) |
| associate a signal to a given process status | |
| bool | Enable (int signalId) |
| associate signal to cuore signal handler | |
| bool | Disable (int signalId) |
| enable handling of a signal | |
| bool | Ignore (int signalId) |
| ignore signal | |
| bool | HasChanged () const |
| tell wehter process status has changed | |
| volatile ProcessStatus_t | GetState () const |
| get current state | |
| volatile ProcessStatus_t | GetPreviousState () const |
| get previous state | |
| volatile 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 | |
| void | SetState (ProcessStatus_t state) |
| change current process status bypassing status queue vector | |
| void | Notify () |
| acknowledge oldest process status contained in staus queue vector | |
| volatile bool | isRunning () const |
| check wether current process status is QRunning_s | |
| volatile bool | isPaused () const |
| check wether current process status is QPaused_s | |
| volatile bool | isIdle () const |
| check wether current process status is QIdle_s | |
| volatile bool | isReady () const |
| check wether current process status is QReady_s | |
| volatile bool | TrgCtrlEnabled () const |
| check wether trigger control signals are enabled | |
| const std::string & | GetError () const |
| get error string | |
| void | SetError (const std::string &errMsg) |
| set error string | |
| bool | isError () const |
| check wether an error occurred | |
| void | SetTrgCtrlEnabled (bool enabled) |
| enable or disable trigger status control | |
| void | InformServer () |
| inform Daq Server about current process status | |
| void | SetName (const std::string &name) |
| set process name that will be used for communication with message logger server | |
Static Public Member Functions | |
| static QProcessStatus & | GetInstance () |
| get singleton Instance | |
Private Member Functions | |
| QProcessStatus () | |
| declare signal handler for handled signals, set error string to an empty string and disable by default trigger control signals | |
| 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. | |
| void | AssociateDefaults () |
| associate default signals to be caught | |
| void | AddToQueue (ProcessStatus_t state) |
| add state to process status queue. | |
| ProcessStatus_t | GetLastStatus () const |
| get last status that have been added to status queue. If queue is empty current process status is returned. | |
| bool | CanBeHandled (int signalId) const |
| check wether requested signal can be handled | |
| bool | CanBeDisabled (int signalId) const |
| check wether requested signal can be disabled | |
Private Attributes | |
| ProcessStatus_t | fState |
| current process status | |
| ProcessStatus_t | fPreviousState |
| previous process status | |
| bool | fTrgCtrl |
| determine wether trigger control signals are enabled (default is disabled) | |
| bool | fInformEnabled |
| determine wether to inform server about changes of state | |
| const size_t | kMaxQueued |
| maximum number of not-notified process statuses. If process queue exceeds this size a warning is sent to stderr. | |
| std::deque< ProcessStatus_t > | fStatusQueue |
| vector containing stauts evolution for current process contains all status changes that are newer than current state | |
| std::string | fError |
| error string | |
| std::map< int, ProcessStatus_t > | fSigMap |
| map of system signal and associated process status | |
Friends | |
| void | SigHandler (int) |
| signal handler function | |
| bool QProcessStatus::Associate | ( | int | signalId, | |
| ProcessStatus_t | pStatus | |||
| ) |
associate a signal to a given process status
| signalId | system signal to be associated to status pStatus | |
| pStatus | process status to be associated to signal signalId |
| bool QProcessStatus::Enable | ( | int | signalId | ) |
associate signal to cuore signal handler
| signalId | signal to be enabled. This signal must be already associated to a value of ProcessStatus_t. |
| void QProcessStatus::SetState | ( | ProcessStatus_t | state | ) |
change current process status bypassing status queue vector
| state | new process status |
| volatile bool QProcessStatus::isRunning | ( | ) | const [inline] |
check wether current process status is QRunning_s
| volatile bool QProcessStatus::isPaused | ( | ) | const [inline] |
| volatile bool QProcessStatus::isIdle | ( | ) | const [inline] |
| volatile bool QProcessStatus::isReady | ( | ) | const [inline] |
| volatile bool QProcessStatus::TrgCtrlEnabled | ( | ) | const [inline] |
check wether trigger control signals are enabled
| const std::string& QProcessStatus::GetError | ( | ) | const [inline] |
get error string
| void QProcessStatus::SetError | ( | const std::string & | errMsg | ) | [inline] |
set error string
| errMsg | error message |
| void QProcessStatus::SetTrgCtrlEnabled | ( | bool | enabled | ) | [inline] |
enable or disable trigger status control
| enable | if true, trigger control is enabled (default is disabled) |
| void QProcessStatus::InformServer | ( | ) |
inform Daq Server 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.
| void QProcessStatus::SetName | ( | const std::string & | name | ) | [inline] |
set process name that will be used for communication with message logger server
| name | process name |
| void QProcessStatus::HandleSignal | ( | int | signalId | ) | [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 |
| void QProcessStatus::AddToQueue | ( | ProcessStatus_t | state | ) | [private] |
add state to process status queue.
| state | status to be added to queue |
| void SigHandler | ( | int | ) | [friend] |
signal handler function
| signalId | signal to be handled |
1.5.1