Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Explain void (*signal(int signo, void *(func)(int)))(int)

Please explain this type signature : void (*signal(int signo, void *(func)(int)))(int)

like image 296
Abhijeet Rastogi Avatar asked Feb 16 '10 04:02

Abhijeet Rastogi


1 Answers

The type signature of the signal function is a bit more clear when a typedef is used for the function pointers that are passed around:

typedef void (*sighandler_t)(int);
sighandler_t signal(int signo, sighandler_t func);

sighandler_t is a pointer to a function that takes an int parameter and returns nothing. The signal function takes such a function pointer as its second parameter. It also returns a function pointer of that type.

like image 69
sth Avatar answered Oct 21 '22 13:10

sth