HP-UX Reference (11i v1 05/09) - 2 System Calls (vol 5)
s
signal(2) signal(2)
sig can be any one of the signals described under signal(5) except
SIGKILL or SIGSTOP.
func is assigned one of four values:
SIG_DFL
, SIG_IGN, SIG_HOLD, or a function address. The
actions prescribed by
SIG_DFL and SIG_IGN are described under signal(5). The action
prescribed by
SIG_HOLD and function address are described below:
SIG_HOLD Hold signal. The signal sig is held upon receipt. Any pending signal of
this signal type remains held. Only one signal of each type is held.
Note: the signals SIGKILL, SIGCONT, and
SIGSTOP cannot be
held.
function address Catch signal. func must be a pointer to a function, the signal- catch-
ing handler, that is called when signal sig occurs.
sigset()
specifies that the process calls this function upon receipt of signal sig.
Any pending signal of this type is released. This handler address is
retained across calls to the other signal management functions listed
here. Upon receipt of signal sig, the receiving process executes the
signal-catching function pointed to by func as described under sig-
nal(5) with the following differences:
Before calling the signal-catching handler, the system signal action of
sig is set to
SIG_HOLD. During a normal return from the
signal-catching handler, the system signal action is restored to func
and any held signal of this type is released. If a non-local goto
(longjmp(3C)) is taken, sigrelse() must be called to restore the
system signal action to func and release any held signal of this type.
sighold() holds the signal sig. sigrelse() restores the system signal action of sig to that specified
previously by sigset(). sighold() and sigrelse() are used to establish critical regions of code.
sighold() is analogous to raising the priority level and deferring or holding a signal until the priority is
lowered by sigrelse() .
sigignore() sets the action for signal sig to SIG_IGN (see signal(5)).
sigpause() suspends the calling process until it receives an unblocked signal. If the signal sig is held, it
is released before the process pauses.
sigpause() is useful for testing variables that are changed when
a signal occurs. For example, sighold() should be used to block the signal first, then test the variables.
If they have not changed, call sigpause() to wait for the signal.
These functions can be linked into a program by giving the -lV3 option to the ld
command (see ld(1)).
ERRORS
sigset() fails and the system signal action for sig is not changed if any of the following occur:
[EFAULT] The func argument points to memory that is not a valid part of the process address
space. Reliable detection of this error is implementation-dependent.
sigset(), sighold(), sigrelse() , sigignore(), and sigpause() fail and the system signal
action for sig is not changed if any of the following occur:
[EINVAL] An attempt is made to ignore, hold, or supply a handler for a signal that cannot be
ignored, held, or caught; see signal(5).
sigpause returns when the following occurs:
[EINTR] A signal was caught.
EXAMPLES
The following call to signal() sets up a signal-catching function for the SIGINT signal:
void myhandler();
(void) signal(SIGINT, myhandler);
WARNINGS
signal() should not be used in conjunction with the facilities described under bsdproc(3C), sigaction(2),
sigset(3C), or sigvector(2).
signal() does not detect an invalid value for action, and if it does not equal SIG_DFL or SIG_IGN,
or point to a valid function address, subsequent receipt of the signal sig causes undefined results.
HP-UX 11i Version 1: September 2005 − 2 − Hewlett-Packard Company Section 2−−373