1.6. Handling UNIX Signals

GenServer class handles UNIX signals. Both SIGINT and SIGTERM terminate the application program. If application code needs to do some special cleaning before terminating, the virtual function GenServer::fatalSignalHook() can be overloaded for that.

Table 1-2. Signal Handling by GenServer class

SignalReaction
SIGINTGenServer::handle_signal()
SIGTERMGenServer::handle_signal()
SIGHUPignore
SIGPIPEignore
SIGCHLDignore
SIGCLDignore
SIGALRMignore
SIGPOLLdo-nothing

It is possible to add, remove or change the way an application program reacts to any of UNIX signals. As can be seen from the class diagram below, GenServer class object includes an instance of SigHandlers class object that is a signal manager and dispatcher. Member function get_sig_manager() returns the handler to the signal dispatcher (Please, see Section 4.12 for additional information).

Figure 1-2. GenServer UNIX Signals Class Diagram

A signal-generated event is delivered to GenServer by the signal dispatcher, SigHandlers, by calling virtual function handle_signal(). Will you find the need of handling additional signals, overload this function in the class derived from GenServer