So can someone explain what this is supposed to do:
void (*signal(int sig, void (*func)(int)) ) (int);
It is a definition taken from the st
Basically it allows to decide how to handle a specific signal (identified by argument int sig
) sent to your program.
The void (*func)(int)
is a pointer to the function that will handle the signal (you can provide a custom one or use SIG_DFL
SIG_IGN
which are default actions to manage it normally or ignore it).
The function signal
then returns the pointer to the handler present BEFORE the call of this function or SIG_ERR
is an error occurred. This can be used to restore the default handler lately when you've done with custom behaviour.