HP-UX Reference (11i v2 04/09) - 2 System Calls (vol 5)
s
sigvector(2) sigvector(2)
(TO BE OBSOLETED)
NAME
sigvector - software signal facilities
SYNOPSIS
#include <signal.h>
int sigvector(
int sig,
const struct sigvec *vec,
struct sigvec *ovec
);
DESCRIPTION
The system defines a set of signals that can be delivered to a process. The set of signals is defined in sig-
nal(5), along with the meaning and side effects of each signal. This manual entry, along with those for
sigblock (2), sigsetmask (2), sigpause (3C), and sigspace (2), defines an alternate mechanism for handling
these signals that ensures the delivery of signals and the integrity of signal handling procedures. The
facilities described here should not be used in the same program as signal (2).
With the
sigvector() interface, signal delivery resembles the occurrence of a hardware interrupt:
the signal is blocked from further occurrence, the current process context is saved, and a new one is built.
A process can specify a handler function to be invoked when a signal is delivered, or specify that a signal
should be blocked or ignored. A process can also specify that a default action should be taken by the sys-
tem when a signal occurs. It is possible to ensure a minimum amount of stack space for processing sig-
nals using sigspace() (see sigspace (2)).
All signals have the same priority. Signal routines execute with the signal that causes their invocation to
be blocked, although other signals can yet occur. A global signal mask defines the set of signals currently
blocked from delivery to a process. The signal mask for a process is initialized from that of its parent
(normally
0). It can be changed with a sigblock(), sigsetmask(),orsigpause() call, or when a
signal is delivered to the process.
A signal mask is represented as a
long, with one bit representing each signal being blocked. The follow-
ing macro defined in <signal.h> is used to convert a signal number to its corresponding bit in the
mask:
#define sigmask(signo) (1L << (signo-1))
When a signal condition arises for a process, the signal is added to a set of signals pending for the pro-
cess. If the signal is not currently blocked by the process, it is delivered to the process. When a signal is
delivered, the current state of the process is saved, a new signal mask is calculated (as described below),
and the signal handler is invoked. The call to the handler is arranged so that if the signal handling rou-
tine returns normally, the process resumes execution in the same context as before the signal’s delivery.
If the process wishes to resume in a different context, it must arrange to restore the previous context
itself.
When a signal is delivered to a process, a new signal mask is installed for the duration of the process’ sig-
nal handler (or until a
sigblock() or sigsetmask() call is made). This mask is formed by taking
the current signal mask, computing the bit-wise inclusive OR with the value of vec .sv_mask (see below)
from the most recent call to sigvector() for the signal to be delivered, and, unless the
SV_RESETHAND flag is set (see below), setting the bit corresponding to the signal being delivered. When
the user’s signal handler returns normally, the original mask is restored.
sigvector() assigns a handler for the signal specified by sig. vec and ovec are pointers to sigvec struc-
tures that include the following elements:
void (*sv_handler )();
long sv_mask ;
long sv_flags;
If vec is non-zero, it specifies a handler routine (sv_handler ), a mask (sv_mask ) that the system should
use when delivering the specified signal, and a set of flags (sv_flags ) that modify the delivery of the sig-
nal. If ovec is non-zero, the previous handling information for the signal is returned to the user. If vec is
zero, signal handling is unchanged. Thus, the call can be used to enquire about the current handling of a
given signal. If vec and ovec point to the same structure, the value of vec is read prior to being overwrit-
ten.
HP-UX 11i Version 2: September 2004 − 1 − Hewlett-Packard Company Section 2−−397