|
Gaudi Framework, version v21r10p1 |
| Home | Generated: 29 Jul 2010 |


Public Types | |
| typedef struct sigaction | handler_t |
Public Member Functions | |
| void | monitorSignal (int signum, bool propagate) |
| Declare a signal to be monitored. | |
| void | ignoreSignal (int signum) |
| Remove the specific signal handler for the requested signal, restoring the previous signal handler. | |
| bool | gotSignal (int signum) const |
| Check if the given signal has been received. | |
| void | setSignal (int signum) |
| Set the flag for the given signal, as if the signal was received. | |
| void | clearSignal (int signum) |
| Clear the flag for the given signal, so that a new occurrence can be identified. | |
| SignalMonitorSvc (const std::string &name, ISvcLocator *svcLoc) | |
| Initialize internal variables of the service and set the instance pointer. | |
| virtual | ~SignalMonitorSvc () |
| Stop monitoring signals and clear the instance pointer. | |
Private Types | |
| enum | MonitoringMode { ignored, trap, propagate } |
| Possible monitoring modes. More... | |
Private Member Functions | |
| void | i_handle (int signum) |
Static Private Member Functions | |
| static void | setInstance (SignalMonitorSvc *i) |
| static SignalMonitorSvc * | instance () |
| Method to get the singleton instance. | |
| static void | dispatcher (int signum) |
| Signal handler function. | |
Private Attributes | |
| MonitoringMode | m_monitored [NSIG] |
| Array of flags to keep track of monitored signals. | |
| sig_atomic_t | m_caught [NSIG] |
| Array of flags for received signals. | |
| handler_t | m_defaultAction |
| Helper variable for default signal action. | |
| handler_t | m_oldActions [NSIG] |
| List of replaced signal actions (for the recovery when disable the monitoring). | |
Static Private Attributes | |
| static SignalMonitorSvc * | s_instance = 0 |
| Pointer to the current instance. | |
If instantiated, intercepts the system signals and keep track of the recorded ones.
The signal to be monitored have to be declared via the method monitorSignal(). It can be interrogated to check if a signal has been received.
Definition at line 26 of file SignalMonitorSvc.cpp.
typedef struct sigaction Gaudi::Utils::SignalMonitorSvc::handler_t [read] |
Definition at line 31 of file SignalMonitorSvc.cpp.
enum Gaudi::Utils::SignalMonitorSvc::MonitoringMode [private] |
Possible monitoring modes.
Definition at line 112 of file SignalMonitorSvc.cpp.
00112 { 00113 ignored, //< the signal is not monitored 00114 trap, //< the signal is monitored and not propagated to previously registered handlers 00115 propagate //< the signal is monitored and propagated to previously registered handlers 00116 };
| Gaudi::Utils::SignalMonitorSvc::SignalMonitorSvc | ( | const std::string & | name, | |
| ISvcLocator * | svcLoc | |||
| ) | [inline] |
Initialize internal variables of the service and set the instance pointer.
Definition at line 85 of file SignalMonitorSvc.cpp.
00085 : base_class(name, svcLoc) { 00086 #ifdef _WIN32 00087 m_defaultAction = SIG_DFL; 00088 #else 00089 m_defaultAction.sa_handler = SIG_DFL; 00090 sigemptyset(&m_defaultAction.sa_mask); 00091 m_defaultAction.sa_flags = 0; 00092 #endif 00093 for(int i = 0; i < NSIG; ++i){ 00094 m_caught[i] = 0; 00095 m_monitored[i] = ignored; 00096 m_oldActions[i] = m_defaultAction; 00097 } 00098 00099 setInstance(this); 00100 }
| virtual Gaudi::Utils::SignalMonitorSvc::~SignalMonitorSvc | ( | ) | [inline, virtual] |
Stop monitoring signals and clear the instance pointer.
Definition at line 103 of file SignalMonitorSvc.cpp.
00103 { 00104 for (int i = 0; i < NSIG; ++i) { 00105 ignoreSignal(i); 00106 } 00107 setInstance(0); 00108 }
| void Gaudi::Utils::SignalMonitorSvc::monitorSignal | ( | int | signum, | |
| bool | propagate | |||
| ) | [inline, virtual] |
Declare a signal to be monitored.
It installs a signal handler for the requested signal.
Implements ISignalMonitor.
Definition at line 36 of file SignalMonitorSvc.cpp.
00036 { 00037 if (!m_monitored[signum]) { 00038 handler_t sa; 00039 handler_t oldact; 00040 #ifdef _WIN32 00041 sa = SignalMonitorSvc::dispatcher; 00042 oldact = signal(signum, sa); 00043 #else 00044 sa.sa_handler = SignalMonitorSvc::dispatcher; 00045 sigemptyset(&sa.sa_mask); 00046 sa.sa_flags = 0; 00047 sigaction(signum, &sa, &oldact); 00048 #endif 00049 m_oldActions[signum] = oldact; 00050 m_monitored[signum] = (propagate) ? SignalMonitorSvc::propagate 00051 : SignalMonitorSvc::trap; 00052 } 00053 }
| void Gaudi::Utils::SignalMonitorSvc::ignoreSignal | ( | int | signum | ) | [inline, virtual] |
Remove the specific signal handler for the requested signal, restoring the previous signal handler.
Implements ISignalMonitor.
Definition at line 57 of file SignalMonitorSvc.cpp.
00057 { 00058 if (m_monitored[signum]) { 00059 #ifdef _WIN32 00060 (void) signal(signum, m_oldActions[signum]); 00061 #else 00062 sigaction(signum, &m_oldActions[signum], 0); 00063 #endif 00064 m_oldActions[signum] = m_defaultAction; 00065 m_monitored[signum] = ignored; 00066 } 00067 }
| bool Gaudi::Utils::SignalMonitorSvc::gotSignal | ( | int | signum | ) | const [inline, virtual] |
Check if the given signal has been received.
Implements ISignalMonitor.
Definition at line 70 of file SignalMonitorSvc.cpp.
00070 { 00071 return m_caught[signum] != 0; 00072 }
| void Gaudi::Utils::SignalMonitorSvc::setSignal | ( | int | signum | ) | [inline, virtual] |
Set the flag for the given signal, as if the signal was received.
Implements ISignalMonitor.
Definition at line 75 of file SignalMonitorSvc.cpp.
00075 { 00076 m_caught[signum] = 1; 00077 }
| void Gaudi::Utils::SignalMonitorSvc::clearSignal | ( | int | signum | ) | [inline, virtual] |
Clear the flag for the given signal, so that a new occurrence can be identified.
Implements ISignalMonitor.
Definition at line 80 of file SignalMonitorSvc.cpp.
00080 { 00081 m_caught[signum] = 0; 00082 }
| void Gaudi::Utils::SignalMonitorSvc::i_handle | ( | int | signum | ) | [inline, private] |
Definition at line 126 of file SignalMonitorSvc.cpp.
00126 { 00127 m_caught[signum] = 1; 00128 if ( m_monitored[signum] == propagate && 00129 #ifdef _WIN32 00130 m_oldActions[signum] != SIG_DFL 00131 #else 00132 m_oldActions[signum].sa_handler != SIG_DFL 00133 #endif 00134 ) { 00135 #ifdef _WIN32 00136 m_oldActions[signum](signum); 00137 #else 00138 m_oldActions[signum].sa_handler(signum); 00139 #endif 00140 } 00141 }
| static void Gaudi::Utils::SignalMonitorSvc::setInstance | ( | SignalMonitorSvc * | i | ) | [inline, static, private] |
| static SignalMonitorSvc* Gaudi::Utils::SignalMonitorSvc::instance | ( | ) | [inline, static, private] |
Method to get the singleton instance.
Bypass the serviceLocator for efficiency.
Definition at line 152 of file SignalMonitorSvc.cpp.
00152 { 00153 return s_instance; 00154 }
| void Gaudi::Utils::SignalMonitorSvc::dispatcher | ( | int | signum | ) | [static, private] |
MonitoringMode Gaudi::Utils::SignalMonitorSvc::m_monitored[NSIG] [private] |
Array of flags to keep track of monitored signals.
Definition at line 118 of file SignalMonitorSvc.cpp.
sig_atomic_t Gaudi::Utils::SignalMonitorSvc::m_caught[NSIG] [private] |
handler_t Gaudi::Utils::SignalMonitorSvc::m_defaultAction [private] |
handler_t Gaudi::Utils::SignalMonitorSvc::m_oldActions[NSIG] [private] |
List of replaced signal actions (for the recovery when disable the monitoring).
Definition at line 124 of file SignalMonitorSvc.cpp.
Gaudi::Utils::SignalMonitorSvc * Gaudi::Utils::SignalMonitorSvc::s_instance = 0 [static, private] |