Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

bsd_signal - simplified signal handling

&pagelevel(4)&pagelevel

Syntax

#include <signal.h>

void ( *bsd_signal(int sig, void ( *func)(int))) (int); 

Description 

The bsd_signal() function provides a partially compatible interface for programs that
were written for old-style system interfaces (see “Notes” below).

The function call bsd_signal(sig, func) acts as though it were implemented as follows:

void (*bsd_signal(int sig, void (*func)(int)))(int)
{
     struct sigaction act, oact;
     act.sa_handler = func;
     act.sa_flags = SA_RESTART;
     sigemptyset(&act.sa_mask);
     sigaddset(&act.sa_mask, sig);
     if (sigaction(sig, &act, &oact) == -1)
          return(SIG_ERR);
     return(oact.sa_handler);
}


The event handling function should be declared as follows:

void handler(int sig);

where sig stands for the signal number. The behavior is not defined if func is a function which
has more than one argument or an argument of a different type.

Return val.

The preceding action for sig


if successful.

SIG_ERR

if an error occurs. errno is set to indicate the error.

Errors

Notes

See sigaction()

This function is a direct substitute for the BSD function signal() for simple applications
for which a signal handling function with an argument is installed. If a BSD signal handling
function which expects more than one argument is installed, the application must be
modified such that it uses sigaction(). The bsd_signal() function differs from
signal() in that the SA_RESTART flag is set and SA_RESETHAND is deleted if
bsd_signal() is used. The status of these flags is not specified for signal().

See also

sigaction(), sigaddset(), sigemptyset(), signal(), signal.h .