Write or Register a Signal Handler

You can register any function as a signal handler, provided it has the following characteristics:

The function may handle the signal in one of the following ways:

To establish or register your own signal handler, call the signal function. For example, in the following statement sig_handler is the address of the handling function for signal sig.

signal(sig, sig_handler);

A signal handler remains established until one of the following occurs:

Calling the _freemod function to delete the load module where the signal handler resides deregisters the handler. If the signal is subsequently raised, an operating system exception occurs and the behavior is undefined.

When you register a signal handler for a DLL or multithreaded program, there are additional factors that you should consider.



Signals and Exceptions


Signal and Exception Handlers in DLLs
Signal and Exception Handlers in Multithreaded Programs
Signal and Exception Handling Considerations
Default Signal Handlers