Name
signal
Synopsis
Installs a signal handler
#include <signal.h> void ( *signal( intsig, void (*handler)(int) ) )(int);
The signal() function
specifies a function to be executed when the program receives a
given signal. The parameter handler is a
pointer to a function that takes one argument of type int and has no return value. This pointer
may be the address of a function defined in your program, or one of
two macros defined in the header file signal.h.
The handler argument works in the
following ways (assuming that the call to signal() is successful):
If the
handlerargument is a function pointer, thensignal()installs this function as the routine to be called the next time the program receives the signal designated by the integer parametersig.If the
handlerargument is equal to the macroSIG_DFL, then the next time the program receives the specified signal, the default signal handler routine is called. The default handler’s action for most signals is to terminate the program.If the
handlerargument is equal to the macroSIG_IGN, then the specified signal will be ignored.
If the handler argument points to a
function in the program, then that function is generally installed
as a handler for only one occurrence of the signal, as if the
program called signal() with the
argument SIG_DFL before calling
the handler. To make a handler persistent, you can have your handler
function reinstall itself by calling signal() again. Alternatively, the C standard allows implementations to mask the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access