The Unreliable signal(3) API

The signal(3) function forms the basis for the unreliable signals interface. Its function synopsis is as follows:

#include <signal.h>

void (*signal(int sig, void (*func)(int)))(int)
/* Alternatively */

typedef void (*sig_t)(int);

sig_t signal(int sig, sig_t func);

The first synopsis is rather difficult to decipher. The FreeBSD man(1) page offers a second interpretation of the first. The signal(3) function's first argument sig identifies the signal for which the caller wants to register an action. The second argument func identifies the action or the function pointer.

The return value from signal(3) is the previous action that was established at the time of the call. Alternatively, the value SIG_ERR indicates that ...

Get Advanced UNIX Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.