信号的返回值

我正在阅读有关信号function,定义是:
void (*signal(int sig, void (*func)(int)))(int); 并且返回值是:

If the request can be honored, signal() shall return the value of func for the most recent call to signal() for the specified signal sig. Otherwise, SIG_ERR shall be returned and a positive value shall be stored in errno.

怀疑是:是不是信号无效function? 它应该什么都不返回?

实际的信号处理函数是一个具有void返回的函数。 安装新信号句柄的functionsignal返回先前的信号处理函数指针。

声明函数返回函数指针的语法非常复杂,难以破译(你必须跟踪所有这些括号)。 如果有一个typedef会更容易,就像在Linux中完成的那样(来自Linux signal手册页 ):

 typedef void (*sighandler_t)(int); sighandler_t signal(int signum, sighandler_t handler); 

另请注意, signal函数被认为已弃用,有利于sigaction