HP-UX Reference (11i v2 03/08) - 3 Library Functions N-Z (vol 7)
s
sigpause(3C) sigpause(3C)
NAME
sigpause - atomically release blocked signals and wait for interrupt
SYNOPSIS
#include <signal.h>
long sigpause(long mask);
DESCRIPTION
sigpause() blocks signals according to the value of mask in the same manner as sigsetmask (2), then
atomically waits for an unmasked signal to arrive. On return,
sigpause() restores the current signal
mask to the value that existed before the
sigpause() call. When no signals are to be blocked, a value
of
0L is used for mask.
In normal usage, a signal is blocked using
sigblock() (see sigblock (2)). To begin a critical section,
variables modified on the occurrence of the signal are examined to determine that there is no work to be
done, and the process pauses, awaiting work by using
sigpause() with the mask returned by sig-
block().
RETURN VALUE
sigpause() terminates when it is interrupted by a signal. When
sigpause() terminates, it returns
−l and sets
errno to EINTR.
EXAMPLES
The following call to sigpause() waits until the calling process receives a signal:
sigpause (0L);
The following example blocks the SIGIO signal until sigpause() is called. When a signal is received at
the sigpause() statement, the signal mask is restored to its value before sigpause() was called:
long savemask;
savemask = sigblock (sigmask (SIGIO));
/∗ critical section ∗/
sigpause (savemask);
WARNINGS
Check all references to signal(5) for appropriateness on systems that support sigvector (2).
sigvec-
tor() can affect the behavior described on this page.
Do not use
sigpause() in conjunction with the facilities described under sigset(3C).
APPLICATION USAGE
Threads Considerations
Since blocked signal masks are maintained at the thread level,
sigpause() modifies only the calling
thread’s blocked signal mask. sigpause() suspends only the calling thread until it receives a signal.
If other threads in the process do not block the signal, the signal may be delivered to another thread in
the process and the thread in
sigpause() may continue waiting. For this reason, the use of sigwait (2)
is recommended instead of sigpause() for multi-threaded applications.
For more information regarding signals and threads, refer to signal(5).
LP64 Programs
sigpause() accepts a long (64 bit) value. However, as for ILP32 programs, sigpause() supports
signals numbered 1 through 32. The upper 32 bits of the mask argument are ignored.
AUTHOR
sigpause() was developed by the University of California, Berkeley.
SEE ALSO
sigblock(2), sigsetmask(2), sigsuspend(2), sigvector(2), sigwait(2).
HP-UX 11i Version 2: August 2003 − 1 − Hewlett-Packard Company Section 3−−957