bsd_signal()

replacement for BSD signal() function 

Function


SYNOPSIS

#include <signal.h>

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


DESCRIPTION

The bsd_signal() function provides a partially compatible interface for programs written to historical system interfaces. This function is a direct replacement for the BSD signal() function for simple applications that are installing a single-argument signal handler function. If a BSD signal handler function is being installed that expects more than one argument, the application has to be modified to use sigaction(). The bsd_signal() function differs from signal() in that the SA_RESTART flag is set and the SA_RESETHAND flag is clear when bsd_signal() is used.

The function call bsd_signal(sig, func) has an effect as if implemented as:

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 handler function should be declared as:

void handler(int sig);

where sig is the signal number. The behavior is undefined if func is a function that takes more than one argument, or an argument of a different type.


PARAMETERS

sig 

Is the signal number for which the signal is to be installed.

func 

Is the signal handler function, declared as shown above.


RETURN VALUES

On success, bsd_signal() returns the previous action for sig. Otherwise, SIG_ERR is returned, and errno is set to one of the following values:

EINVAL 

The value of sig is an invalid or unsupported signal number, or bsd_signal() attempted to catch a signal that cannot be caught, or the function tried to ignore a signal that cannot be ignored.


CONFORMANCE

UNIX 98


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
sigaction(), sigaddset(), sigemptyset(), signal()


PTC MKS Toolkit 10.4 Documentation Build 39.