Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 |
both | POSIX(ON) |
#define _XOPEN_SOURCE_EXTENDED 1
#include <signal.h>
void (*bsd_signal(int sig, void (*func)(int)))(int);
The bsd_signal() function provides a partially compatible interface for programs written to use the BSD form of the signal() function.
BSD signal() differs from ANSI signal() in that the SA_RESTART flag is set and the SA_RESETHAND is cleared when bsd_signal() is used. Whereas for signal() both of these flags are cleared and _SA_OLD_STYLE is set.
There are three functions available for establishing a signal's action, signal(), bsd_signal(), and sigaction(). The sigaction() function is the strategic way to establish a signal's action. The bsd_signal() and signal() functions are provided for compatibility with BSD and ANSI, respectively.
The argument sig is the signal type. See Table 1 for a list of the supported signal types or refer to the <signal.h> header. The argument func is the signal action. It may be set to SIG_DFL, SIG_IGN, or the address of a signal catching function that takes one input argument.
Special Behavior for C++
Because C and C++ linkage conventions are incompatible, bsd_signal() cannot receive a C++ function pointer as the start routine function pointer If you attempt to pass a C++ function pointer to bsd_signal(), the compiler will flag it as an error. You can pass a C or C++ function to bsd_signal() by declaring it as extern "C".
If successful, bsd_signal() returns the previous action established for this signal type.