bsd_signal(3C) bsd_signal(3C)
NAME
bsdsignal - simplified signal facilities
SYNOPSIS
#include <signal.h>
void (*bsdsignal(int sig, void (*func)(int)))(int);
DESCRIPTION
The bsdsignal() function provides a partially compatible interface
for programs written to historical system interfaces (see APPLICATION
USAGE below).
The function call bsdsignal(sig, func) has an effect as if imple-
mented as:
void (*bsdsignal(int sig, void (*func)(int)))(int)
{
struct sigaction act, oact;
act.sahandler = func;
act.saflags = SARESTART;
sigemptyset(&act.samask);
sigaddset(&act.samask, sig);
if (sigaction(sig, &act, &oact) == -1)
return(SIGERR);
return(oact.sahandler);
}
The handler function should be declared:
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 dif-
ferent type.
RETURN VALUE
Upon successful completion, bsdsignal() returns the previous action
for sig. Otherwise, SIGERR is returned and errno is set to indicate
the error.
ERRORS
Refer to sigaction(2).
APPLICATION USAGE
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 modi-
fied to use sigaction(). The bsdsignal() function differs from sig-
nal() in that the SARESTART flag is set and the SARESETHAND will be
Page 1 Reliant UNIX 5.44 Printed 11/98
bsd_signal(3C) bsd_signal(3C)
clear when bsdsignal() is used. The state of these flags is not
specified for signal().
SEE ALSO
sigaction(2), signal(3-ucb), sigaddset(3C), sigemptyset(3C), sig-
nal(5).
Page 2 Reliant UNIX 5.44 Printed 11/98