2.9.2 signal


void (*signal(int sig, void (*func)(int)))(int);

Controls how a signal is handled. sig represents the signal number compatible with the SIG macros. func is the function to be called when the signal occurs. If func isSIG_DFL, then the default handler is called. If func is SIG_IGN, then the signal is ignored. If func points to a function, then when a signal is detected the default function is called (SIG_DFL), then the function is called. The function must take one argument of type int which represents the signal number. The function may terminate with returnabortexit, or longjmp. When the function terminates execution resumes where it was interrupted (unless it was a SIGFPE signal in which case the result is undefined).

If the call to signal is successful, then it returns a pointer to the previous signal handler for the specified signal type. If the call fails, then SIG_ERR is returned anderrno is set appropriately.