476 Chapter 22
disposition to ignore. The sigpause() function is similar to sigsuspend(), but removes
just one signal from the process signal mask before suspending the process until
the arrival of a signal.
The BSD signal API
The POSIX signal API drew heavily on the 4.2BSD API, so the BSD functions are
mainly direct analogs of those in POSIX.
As with the functions in the System V signal API described above, we present
the prototypes of the functions in the BSD signal API, and briefly explain the oper-
ation of each function. Once again, the manual pages provide full details.
The sigvec() function is analogous to sigaction(). The vec and ovec arguments are
pointers to structures of the following type:
struct sigvec {
void (*sv_handler)();
int sv_mask;
int sv_flags;
};
The fields of the sigvec structure correspond closely with those of the sigaction struc-
ture. The first notable difference is that the sv_mask field (the analog of sa_mask)
was an integer rather than a sigset_t, which meant that, on 32-bit architectures,
there was a maximum of 31 different signals. The other difference is the use of the
SV_INTERRUPT flag in the sv_flags field (the analog of sa_flags). Since system call
restarting was the default on 4.2BSD, this flag was used to specify that slow system
calls should be interrupted by signal handlers. (This contrasts with the POSIX API,
where we must explicitly specify SA_RESTART in order to enable restarting of system
calls when establishing a signal handler with sigaction().)
#define _BSD_SOURCE
#include <signal.h>
int sigvec(int sig, struct sigvec *vec, struct sigvec *ovec);
Returns 0 on success, or –1 on error
#define _BSD_SOURCE
#include <signal.h>
int sigblock(int mask);
int sigsetmask(int mask);
Both return previous signal mask
int sigpause(int sigmask);
Always returns –1 with errno set to EINTR
int sigmask(sig);
Returns signal mask value with bit sig set