I'm analyzing a C program in which I find a strange fucntion call here is the function definition :
static void endSignal (int32_t dummy)
{
if (nTerminating) return;
nTerminating=1;
printf("terminating....\n");
terminateDLNAsystem();
sleep(1);
exit (0);
}
This function takes an int32_t parameter ! Now this the main function calling "endSignal"
int32_t main (int32_t argc, char **argv)
{
/*Statements
.
.
*/
signal(SIGINT, endSignal);
signal(SIGABRT, endSignal);
signal(SIGQUIT, endSignal);
signal(SIGTERM, endSignal);
return 0;
}
the main function call endSignal without any parameter, what happen in this case ?
Main function calls signal
functions and not endSignal
.
endSignal
is parameter acting as callback.
This is passing function pointers as arguments.