4.12. SigHandlers Class

SigHandlers class extends SigHandler class by allowing user to register multiple EventHandlers per signal. It also preserves signal handlers already installed by the third-party software (such as other libraries you application might be linked to).

4.12.1. DEFINITION

		  
class SigHandlers : public SigHandler
{
public:
    static void sighandlers_dispatcher (int signum_);

    virtual int install (int            signum_,
                         EventHandler*  new_hand_,
                         SigAction*     new_disp_ = 0,
                         EventHandler** old_hand_ = 0,
                         SigAction*     old_disp_ = 0);

     virtual int remove (int           signum_, 
                         EventHandler* eh_,
                         SigAction*    new_disp_ = 0, 
                         SigAction*    old_disp_ = 0);
};
	  

Initially the state of the SigHandlers object is passive. No special dispatching is done. User can use other means (such as mentioned in Section 4.10) to register "C" function as a signal handler.

When register() method is called for the first EventHandler, the state of SigHandlers object changes to active, and SigHandlers dispatcher takes the control over the signal dispatching. Each new EventHandler is added to the list of handlers already installed. When signal is delivered, all handlers on that list are called in the order of their installation.

If a third party library (or application code) has installed its own "C" signal handler function prior to the first EventHandler registration, it would be added to the list of other registered EventHandlers and notified accordingly when signal is delivered to the process by the operating system.