Gaudi::Utils::SignalMonitorSvc Class Reference

Implementation of Gaudi::ISignalMonitor. More...

Inheritance diagram for Gaudi::Utils::SignalMonitorSvc:
Collaboration diagram for Gaudi::Utils::SignalMonitorSvc:

Public Types

typedef struct sigaction handler_t
 
- Public Types inherited from extends1< Service, Gaudi::ISignalMonitor >
typedef extends1 base_class
 Typedef to this class. More...
 
typedef extends1 base_class
 Typedef to this class. More...
 
typedef extend_interfaces1< Gaudi::ISignalMonitorextend_interfaces_base
 Typedef to the base of this class. More...
 
typedef extend_interfaces1< Gaudi::ISignalMonitorextend_interfaces_base
 Typedef to the base of this class. More...
 
typedef extend_interfaces_base::ext_iids interfaces
 MPL set of all the implemented interfaces. More...
 
typedef extend_interfaces_base::ext_iids interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
typedef CommonMessaging base_class
 
typedef CommonMessaging base_class
 
- Public Types inherited from implements3< IService, IProperty, IStateful >
typedef implements3 base_class
 Typedef to this class. More...
 
typedef implements3 base_class
 Typedef to this class. More...
 
typedef extend_interfaces3< IService, IProperty, IStatefulextend_interfaces_base
 Typedef to the base of this class. More...
 
typedef extend_interfaces3< IService, IProperty, IStatefulextend_interfaces_base
 Typedef to the base of this class. More...
 
typedef extend_interfaces_base::ext_iids interfaces
 MPL set of all the implemented interfaces. More...
 
typedef extend_interfaces_base::ext_iids interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from extend_interfaces3< IService, IProperty, IStateful >
typedef mpl::fold< typename IService::iid::iids::type, typename mpl::fold< typename IProperty::iid::iids::type, typename IStateful::iid::iids::type, mpl::insert< mpl::_1, mpl::_2 > >::type, mpl::insert< mpl::_1, mpl::_2 > >::type ext_iids
 MPL set of interfaces extended by this one. More...
 
typedef mpl::fold< typename IService::iid::iids::type, typename mpl::fold< typename IProperty::iid::iids::type, typename IStateful::iid::iids::type, mpl::insert< mpl::_1, mpl::_2 > >::type, mpl::insert< mpl::_1, mpl::_2 > >::type ext_iids
 MPL set of interfaces extended by this one. More...
 
- Public Types inherited from IInterface
enum  Status {
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR,
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR
}
 Return status. More...
 
enum  Status {
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR,
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR
}
 Return status. More...
 
typedef Gaudi::InterfaceId< IInterface, 0, 0 > iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 
typedef Gaudi::InterfaceId< IInterface, 0, 0 > iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 
- Public Types inherited from extend_interfaces1< Gaudi::ISignalMonitor >
typedef Gaudi::ISignalMonitor::iid::iids::type ext_iids
 MPL set of interfaces extended by this one. More...
 
typedef Gaudi::ISignalMonitor::iid::iids::type ext_iids
 MPL set of interfaces extended by this one. More...
 

Public Member Functions

void monitorSignal (int signum, bool propagate)
 Declare a signal to be monitored. More...
 
void ignoreSignal (int signum)
 Remove the specific signal handler for the requested signal, restoring the previous signal handler. More...
 
bool gotSignal (int signum) const
 Check if the given signal has been received. More...
 
void setSignal (int signum)
 Set the flag for the given signal, as if the signal was received. More...
 
void clearSignal (int signum)
 Clear the flag for the given signal, so that a new occurrence can be identified. More...
 
 SignalMonitorSvc (const std::string &name, ISvcLocator *svcLoc)
 Initialize internal variables of the service and set the instance pointer. More...
 
virtual ~SignalMonitorSvc ()
 Stop monitoring signals and clear the instance pointer. More...
 
- Public Member Functions inherited from extends1< Service, Gaudi::ISignalMonitor >
 extends1 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments. More...
 
 extends1 (A1 a1, A2 a2)
 Templated constructor with 2 arguments. More...
 
 extends1 (A1 a1)
 Templated constructor with 1 argument. More...
 
 extends1 ()
 Default constructor. More...
 
 extends1 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments. More...
 
 extends1 (A1 a1, A2 a2)
 Templated constructor with 2 arguments. More...
 
 extends1 (A1 a1)
 Templated constructor with 1 argument. More...
 
 extends1 ()
 Default constructor. More...
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast. More...
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast. More...
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface. More...
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface. More...
 
virtual std::vector< std::string > getInterfaceNames () const
 Implementation of IInterface::getInterfaceNames. More...
 
virtual std::vector< std::string > getInterfaceNames () const
 Implementation of IInterface::getInterfaceNames. More...
 
virtual ~extends1 ()
 Virtual destructor. More...
 
virtual ~extends1 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
virtual unsigned long release ()
 Release Interface instance. More...
 
virtual const std::string & name () const
 Retrieve name of the service. More...
 
virtual StatusCode configure ()
 Configuration (from OFFLINE to CONFIGURED). More...
 
virtual StatusCode initialize ()
 Initialization (from CONFIGURED to INITIALIZED). More...
 
virtual StatusCode start ()
 Start (from INITIALIZED to RUNNING). More...
 
virtual StatusCode stop ()
 Stop (from RUNNING to INITIALIZED). More...
 
virtual StatusCode finalize ()
 Finalize (from INITIALIZED to CONFIGURED). More...
 
virtual StatusCode terminate ()
 Initialization (from CONFIGURED to OFFLINE). More...
 
virtual Gaudi::StateMachine::State FSMState () const
 Get the current state. More...
 
virtual Gaudi::StateMachine::State targetFSMState () const
 When we are in the middle of a transition, get the state where the transition is leading us. More...
 
virtual StatusCode reinitialize ()
 Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED). More...
 
virtual StatusCode restart ()
 Initialization (from RUNNING to RUNNING, via INITIALIZED). More...
 
virtual StatusCode sysInitialize ()
 Initialize Service. More...
 
virtual StatusCode sysStart ()
 Initialize Service. More...
 
virtual StatusCode sysStop ()
 Initialize Service. More...
 
virtual StatusCode sysFinalize ()
 Finalize Service. More...
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service. More...
 
virtual StatusCode sysRestart ()
 Re-initialize the Service. More...
 
virtual StatusCode setProperty (const Property &p)
 Set the property by property. More...
 
virtual StatusCode setProperty (const std::string &s)
 Set the property by string. More...
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 Set the property by std::string. More...
 
virtual StatusCode getProperty (Property *p) const
 Get the property by property. More...
 
virtual const PropertygetProperty (const std::string &name) const
 Get the property by name. More...
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 Get the property by std::string. More...
 
virtual const std::vector< Property * > & getProperties () const
 Get list of properties. More...
 
virtual bool hasProperty (const std::string &name) const
 Return true if we have a property with the given name. More...
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
virtual unsigned long release ()
 Release Interface instance. More...
 
virtual const std::string & name () const
 Retrieve name of the service. More...
 
virtual StatusCode configure ()
 Configuration (from OFFLINE to CONFIGURED). More...
 
virtual StatusCode initialize ()
 Initialization (from CONFIGURED to INITIALIZED). More...
 
virtual StatusCode start ()
 Start (from INITIALIZED to RUNNING). More...
 
virtual StatusCode stop ()
 Stop (from RUNNING to INITIALIZED). More...
 
virtual StatusCode finalize ()
 Finalize (from INITIALIZED to CONFIGURED). More...
 
virtual StatusCode terminate ()
 Initialization (from CONFIGURED to OFFLINE). More...
 
virtual Gaudi::StateMachine::State FSMState () const
 Get the current state. More...
 
virtual Gaudi::StateMachine::State targetFSMState () const
 When we are in the middle of a transition, get the state where the transition is leading us. More...
 
virtual StatusCode reinitialize ()
 Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED). More...
 
virtual StatusCode restart ()
 Initialization (from RUNNING to RUNNING, via INITIALIZED). More...
 
virtual StatusCode sysInitialize ()
 Initialize Service. More...
 
virtual StatusCode sysStart ()
 Initialize Service. More...
 
virtual StatusCode sysStop ()
 Initialize Service. More...
 
virtual StatusCode sysFinalize ()
 Finalize Service. More...
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service. More...
 
virtual StatusCode sysRestart ()
 Re-initialize the Service. More...
 
virtual StatusCode setProperty (const Property &p)
 Set the property by property. More...
 
virtual StatusCode setProperty (const std::string &s)
 Set the property by string. More...
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 Set the property by std::string. More...
 
virtual StatusCode getProperty (Property *p) const
 Get the property by property. More...
 
virtual const PropertygetProperty (const std::string &name) const
 Get the property by name. More...
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 Get the property by std::string. More...
 
virtual const std::vector< Property * > & getProperties () const
 Get list of properties. More...
 
virtual bool hasProperty (const std::string &name) const
 Return true if we have a property with the given name. More...
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
 CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
 Templated constructor with 3 arguments. More...
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments. More...
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument. More...
 
 CommonMessaging ()
 Default constructor. More...
 
 CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
 Templated constructor with 3 arguments. More...
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments. More...
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument. More...
 
 CommonMessaging ()
 Default constructor. More...
 
virtual ~CommonMessaging ()
 Virtual destructor. More...
 
virtual ~CommonMessaging ()
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces3< IService, IProperty, IStateful >
virtual ~extend_interfaces3 ()
 Virtual destructor. More...
 
virtual ~extend_interfaces3 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IService
 DeclareInterfaceID (IService, 3, 0)
 InterfaceID. More...
 
virtual ~IService ()
 virtual destructor More...
 
 DeclareInterfaceID (IService, 3, 0)
 InterfaceID. More...
 
virtual ~IService ()
 virtual destructor More...
 
- Public Member Functions inherited from INamedInterface
 DeclareInterfaceID (INamedInterface, 1, 0)
 InterfaceID. More...
 
virtual ~INamedInterface ()
 Virtual destructor (always needed for abstract classes). More...
 
 DeclareInterfaceID (INamedInterface, 1, 0)
 InterfaceID. More...
 
virtual ~INamedInterface ()
 Virtual destructor (always needed for abstract classes). More...
 
- Public Member Functions inherited from IInterface
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual ~IInterface ()
 Virtual destructor. More...
 
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual ~IInterface ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IProperty
 DeclareInterfaceID (IProperty, 2, 1)
 InterfaceID. More...
 
 DeclareInterfaceID (IProperty, 2, 1)
 InterfaceID. More...
 
- Public Member Functions inherited from IStateful
 DeclareInterfaceID (IStateful, 1, 0)
 InterfaceID. More...
 
virtual ~IStateful ()
 
 DeclareInterfaceID (IStateful, 1, 0)
 InterfaceID. More...
 
virtual ~IStateful ()
 
- Public Member Functions inherited from extend_interfaces1< Gaudi::ISignalMonitor >
virtual ~extend_interfaces1 ()
 Virtual destructor. More...
 
virtual ~extend_interfaces1 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from Gaudi::ISignalMonitor
 DeclareInterfaceID (ISignalMonitor, 1, 0)
 InterfaceID. More...
 
 DeclareInterfaceID (ISignalMonitor, 1, 0)
 InterfaceID. More...
 

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 SignalMonitorSvcinstance ()
 Method to get the singleton instance. More...
 
static void dispatcher (int signum)
 Signal handler function. More...
 

Private Attributes

MonitoringMode m_monitored [NSIG]
 Array of flags to keep track of monitored signals. More...
 
sig_atomic_t m_caught [NSIG]
 Array of flags for received signals. More...
 
handler_t m_defaultAction
 Helper variable for default signal action. More...
 
handler_t m_oldActions [NSIG]
 List of replaced signal actions (for the recovery when disable the monitoring). More...
 

Static Private Attributes

static SignalMonitorSvcs_instance = 0
 Pointer to the current instance. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 
- Protected Member Functions inherited from Service
virtual ~Service ()
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
virtual ~Service ()
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel
 Service output level. More...
 
Gaudi::StateMachine::State m_state
 Service state. More...
 
Gaudi::StateMachine::State m_targetState
 Service state. More...
 
- Protected Attributes inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
SmartIF< IMessageSvcm_msgsvc
 Pointer to the message service;. More...
 
std::auto_ptr< MsgStreamm_msgStream
 The predefined message stream. More...
 
bool m_streamWithService
 Flag to create a new MsgStream if it was created without the message service. More...
 

Detailed Description

Implementation of Gaudi::ISignalMonitor.

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.

Member Typedef Documentation

typedef struct sigaction Gaudi::Utils::SignalMonitorSvc::handler_t

Definition at line 31 of file SignalMonitorSvc.cpp.

Member Enumeration Documentation

enum Gaudi::Utils::SignalMonitorSvc::MonitoringMode
private

Possible monitoring modes.

Enumerator
ignored 
trap 
propagate 

Definition at line 112 of file SignalMonitorSvc.cpp.

112  {
113  ignored, //< the signal is not monitored
114  trap, //< the signal is monitored and not propagated to previously registered handlers
115  propagate //< the signal is monitored and propagated to previously registered handlers
116  };

Constructor & Destructor Documentation

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.

85  : base_class(name, svcLoc) {
86 #ifdef _WIN32
87  m_defaultAction = SIG_DFL;
88 #else
89  m_defaultAction.sa_handler = SIG_DFL;
90  sigemptyset(&m_defaultAction.sa_mask);
91  m_defaultAction.sa_flags = 0;
92 #endif
93  for(int i = 0; i < NSIG; ++i){
94  m_caught[i] = 0;
97  }
98 
99  setInstance(this);
100  }
sig_atomic_t m_caught[NSIG]
Array of flags for received signals.
extends1 base_class
Typedef to this class.
Definition: extends.h:12
static void setInstance(SignalMonitorSvc *i)
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:329
MonitoringMode m_monitored[NSIG]
Array of flags to keep track of monitored signals.
handler_t m_oldActions[NSIG]
List of replaced signal actions (for the recovery when disable the monitoring).
handler_t m_defaultAction
Helper variable for default signal action.
list i
Definition: ana.py:128
virtual Gaudi::Utils::SignalMonitorSvc::~SignalMonitorSvc ( )
inlinevirtual

Stop monitoring signals and clear the instance pointer.

Definition at line 103 of file SignalMonitorSvc.cpp.

103  {
104  for (int i = 0; i < NSIG; ++i) {
105  ignoreSignal(i);
106  }
107  setInstance(0);
108  }
void ignoreSignal(int signum)
Remove the specific signal handler for the requested signal, restoring the previous signal handler...
static void setInstance(SignalMonitorSvc *i)
list i
Definition: ana.py:128

Member Function Documentation

void Gaudi::Utils::SignalMonitorSvc::clearSignal ( int  signum)
inlinevirtual

Clear the flag for the given signal, so that a new occurrence can be identified.

Implements Gaudi::ISignalMonitor.

Definition at line 80 of file SignalMonitorSvc.cpp.

80  {
81  m_caught[signum] = 0;
82  }
sig_atomic_t m_caught[NSIG]
Array of flags for received signals.
void Gaudi::Utils::SignalMonitorSvc::dispatcher ( int  signum)
staticprivate

Signal handler function.

Definition at line 161 of file SignalMonitorSvc.cpp.

161  {
162  if (instance()) instance()->i_handle(signum);
163  }
static SignalMonitorSvc * instance()
Method to get the singleton instance.
bool Gaudi::Utils::SignalMonitorSvc::gotSignal ( int  signum) const
inlinevirtual

Check if the given signal has been received.

Implements Gaudi::ISignalMonitor.

Definition at line 70 of file SignalMonitorSvc.cpp.

70  {
71  return m_caught[signum] != 0;
72  }
sig_atomic_t m_caught[NSIG]
Array of flags for received signals.
void Gaudi::Utils::SignalMonitorSvc::i_handle ( int  signum)
inlineprivate

Definition at line 126 of file SignalMonitorSvc.cpp.

126  {
127  m_caught[signum] = 1;
128  if ( m_monitored[signum] == propagate &&
129 #ifdef _WIN32
130  m_oldActions[signum] != SIG_DFL
131 #else
132  m_oldActions[signum].sa_handler != SIG_DFL
133 #endif
134  ) {
135 #ifdef _WIN32
136  m_oldActions[signum](signum);
137 #else
138  m_oldActions[signum].sa_handler(signum);
139 #endif
140  }
141  }
sig_atomic_t m_caught[NSIG]
Array of flags for received signals.
MonitoringMode m_monitored[NSIG]
Array of flags to keep track of monitored signals.
handler_t m_oldActions[NSIG]
List of replaced signal actions (for the recovery when disable the monitoring).
void Gaudi::Utils::SignalMonitorSvc::ignoreSignal ( int  signum)
inlinevirtual

Remove the specific signal handler for the requested signal, restoring the previous signal handler.

Implements Gaudi::ISignalMonitor.

Definition at line 57 of file SignalMonitorSvc.cpp.

57  {
58  if (m_monitored[signum]) {
59 #ifdef _WIN32
60  (void) signal(signum, m_oldActions[signum]);
61 #else
62  sigaction(signum, &m_oldActions[signum], 0);
63 #endif
64  m_oldActions[signum] = m_defaultAction;
65  m_monitored[signum] = ignored;
66  }
67  }
MonitoringMode m_monitored[NSIG]
Array of flags to keep track of monitored signals.
handler_t m_oldActions[NSIG]
List of replaced signal actions (for the recovery when disable the monitoring).
handler_t m_defaultAction
Helper variable for default signal action.
static SignalMonitorSvc* Gaudi::Utils::SignalMonitorSvc::instance ( )
inlinestaticprivate

Method to get the singleton instance.

Bypass the serviceLocator for efficiency.

Definition at line 152 of file SignalMonitorSvc.cpp.

152  {
153  return s_instance;
154  }
static SignalMonitorSvc * s_instance
Pointer to the current instance.
void Gaudi::Utils::SignalMonitorSvc::monitorSignal ( int  signum,
bool  propagate 
)
inlinevirtual

Declare a signal to be monitored.

It installs a signal handler for the requested signal.

Implements Gaudi::ISignalMonitor.

Definition at line 36 of file SignalMonitorSvc.cpp.

36  {
37  if (!m_monitored[signum]) {
38  handler_t sa;
39  handler_t oldact;
40 #ifdef _WIN32
42  oldact = signal(signum, sa);
43 #else
44  sa.sa_handler = SignalMonitorSvc::dispatcher;
45  sigemptyset(&sa.sa_mask);
46  sa.sa_flags = 0;
47  sigaction(signum, &sa, &oldact);
48 #endif
49  m_oldActions[signum] = oldact;
52  }
53  }
static void dispatcher(int signum)
Signal handler function.
MonitoringMode m_monitored[NSIG]
Array of flags to keep track of monitored signals.
handler_t m_oldActions[NSIG]
List of replaced signal actions (for the recovery when disable the monitoring).
static void Gaudi::Utils::SignalMonitorSvc::setInstance ( SignalMonitorSvc i)
inlinestaticprivate

Definition at line 146 of file SignalMonitorSvc.cpp.

146  {
147  s_instance = i;
148  }
static SignalMonitorSvc * s_instance
Pointer to the current instance.
list i
Definition: ana.py:128
void Gaudi::Utils::SignalMonitorSvc::setSignal ( int  signum)
inlinevirtual

Set the flag for the given signal, as if the signal was received.

Implements Gaudi::ISignalMonitor.

Definition at line 75 of file SignalMonitorSvc.cpp.

75  {
76  m_caught[signum] = 1;
77  }
sig_atomic_t m_caught[NSIG]
Array of flags for received signals.

Member Data Documentation

sig_atomic_t Gaudi::Utils::SignalMonitorSvc::m_caught[NSIG]
private

Array of flags for received signals.

Definition at line 120 of file SignalMonitorSvc.cpp.

handler_t Gaudi::Utils::SignalMonitorSvc::m_defaultAction
private

Helper variable for default signal action.

Definition at line 122 of file SignalMonitorSvc.cpp.

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.

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
staticprivate

Pointer to the current instance.

Definition at line 144 of file SignalMonitorSvc.cpp.


The documentation for this class was generated from the following file: