HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_Signal Class Reference

#include <UT_Signal.h>

Classes

class  Empty
 

Public Member Functions

 UT_Signal (int signum=0, UToldStyleSigHandler handler=SIG_DFL, bool ignore_prev=false)
 
 UT_Signal (int signum, UTsigHandler handler, bool ignore_prev=false, void *user_data=nullptr)
 
 UT_Signal (const Empty &)
 
template<std::size_t Size>
 UT_Signal (const int(&signums)[Size], UToldStyleSigHandler handler=SIG_DFL, bool ignore_prev=false)
 
template<std::size_t Size>
 UT_Signal (const int(&signums)[Size], UTsigHandler handler, bool ignore_prev=false, void *user_data=nullptr)
 
 UT_Signal (const UT_Array< int > &signums, UTsigHandler handler, bool ignore_prev=false, void *user_data=nullptr)
 
 UT_Signal (const UT_Array< int > &signums, UToldStyleSigHandler handler=SIG_DFL, bool ignore_prev=false)
 
 ~UT_Signal ()
 Destructing will restore the signals to their previous values. More...
 
 UT_Signal (const UT_Signal &)=delete
 
UT_Signaloperator= (const UT_Signal &)=delete
 
void override (int signum, UToldStyleSigHandler, bool ignore_prev=false)
 
void override (int signum, UTsigHandler, bool ignore_prev=false, void *user_data=nullptr)
 
void removeSignal (int sig)
 Remove a specific signal. More...
 

Static Public Member Functions

static void disableCantReturn (bool disable)
 

Detailed Description

Definition at line 171 of file UT_Signal.h.

Constructor & Destructor Documentation

UT_Signal::UT_Signal ( int  signum = 0,
UToldStyleSigHandler  handler = SIG_DFL,
bool  ignore_prev = false 
)
explicit

Catch a specified signal. If signum <= 0, then all signals (except ABRT) are caught. There are two styles of constructors. One takes an old-style signal handler that is needed so we can easily specify SIG_DFL, SIG_IGN, and SIG_ERR as the signal behaviours. The other constructor takes our own data structure as an argument and is designed to support the SA_SIGINFO 3-argument style callback added in POSIX.1b. If ignore_prev is false, all other signal handlers for the raised signal will be called in the reverse order they were installed. Otherwise, only the last handler for this signal will be called.

UT_Signal::UT_Signal ( int  signum,
UTsigHandler  handler,
bool  ignore_prev = false,
void user_data = nullptr 
)
explicit
UT_Signal::UT_Signal ( const Empty )
explicit

This constructor is used when the signals that we want to catch are unknown at the time the signal object is created.

template<std::size_t Size>
UT_Signal::UT_Signal ( const int(&)  signums[Size],
UToldStyleSigHandler  handler = SIG_DFL,
bool  ignore_prev = false 
)
inline

Catch a specified set of signals. The first argument is an array of signal numbers to catch. The array should be null terminated (since there is no signal 0)

Definition at line 201 of file UT_Signal.h.

template<std::size_t Size>
UT_Signal::UT_Signal ( const int(&)  signums[Size],
UTsigHandler  handler,
bool  ignore_prev = false,
void user_data = nullptr 
)
inline

Definition at line 207 of file UT_Signal.h.

UT_Signal::UT_Signal ( const UT_Array< int > &  signums,
UTsigHandler  handler,
bool  ignore_prev = false,
void user_data = nullptr 
)
explicit
UT_Signal::UT_Signal ( const UT_Array< int > &  signums,
UToldStyleSigHandler  handler = SIG_DFL,
bool  ignore_prev = false 
)
explicit
UT_Signal::~UT_Signal ( )

Destructing will restore the signals to their previous values.

UT_Signal::UT_Signal ( const UT_Signal )
delete

Member Function Documentation

static void UT_Signal::disableCantReturn ( bool  disable)
static

This disables the cant return behaviour used in UT_Signal. This behaviour will abort the application on behalf of the application itself for signals that it treats as cant return (i.e. SIGTERM). For some applications the application needs to control the full shutdown otherwise the application can end up erroring on exit.

UT_Signal& UT_Signal::operator= ( const UT_Signal )
delete
void UT_Signal::override ( int  signum,
UToldStyleSigHandler  ,
bool  ignore_prev = false 
)

The following method is made available to override the default handler without destructing the object. For example, in the signal handler, you may want to ignore further signals of a certain type. This method allows you to set the signals. In fact, it simply calls sigaction() with the new handler.

void UT_Signal::override ( int  signum,
UTsigHandler  ,
bool  ignore_prev = false,
void user_data = nullptr 
)
void UT_Signal::removeSignal ( int  sig)

Remove a specific signal.


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