Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
sigaction(2) OSS System Calls Reference Manual
threads), or sigsuspend() function. If and when the signal-catching function returns normally, the
original signal mask is restored, regardless of any modifications made by the sigprocmask() or
pthread_sigmask( ) function since the signal-catching function was invoked.
The SIGKILL, SIGSTOP, and SIGABEND signals cannot be blocked. If a program attempts to
block any of these signals, the system removes them from the signal mask without generating an
error. For example, if a call to sigaction() tries to block the SIGKILL signal and then a subse-
quent call returns the signal-handling information in the structure pointed to by the o_action
parameter, the returned mask is not the same mask that the original call passed in; the difference
is that the returned mask does not include the SIGKILL signal.
Specifying Options
If the sigaltstack() function is used to specify an alternate signal stack for a user signal handler,
and the alternate signal stack is registered and enabled, then all user signal handlers run on the
alternate signal stack.
Unless you are using the Standard POSIX Threads library, although the SA_ONSTACK flag has
no effect in the Guardian environment, to allow code portability, the SA_ONSTACK flag will be
recognized on systems running J06.10 or later RVUs or H06.21 or later RVUs, if the
SA_ONSTACK_COMPATIBILITY feature test macro is set. You should NOT use the
SA_ONSTACK flag and the SA_ONSTACK_COMPATIBILITY feature test macro in a
threaded application that uses the Standard POSIX Threads library. Use of these two options
with the Standard POSIX Threads library can result in undefined behavior in the SPT environ-
ment.
Unless you are using the Standard POSIX Threads library, the sa_flags field can have the
SA_NOCLDSTOP bit set to specify further control over the actions taken on delivery of a sig-
nal. If the signal parameter is SIGCHLD and a child process of the calling process stops, a
SIGCHLD signal is sent to the calling process unless SA_NOCLDSTOP is set for SIGCHLD.
Use From a Threaded Application
The thread-aware sigaction() function allows the calling thread to change or examine the action
to be taken on delivery of a specific signal. This call removes any previously established signal
handler for this signal for this thread. You must reestablish the previous signal handler if you
want to use it at a later time.
The thread-aware signal is always enabled in the POSIX User Thread Model library so that
externally generated signals (such as SIGINT, SIGQUIT, SIGALRM, and SIGCHLD) are
catchable by threads. When the thread library signal handler receives the signal, it will check to
see if the current thread can handle the signal. If the current thread can handle the signal, then the
thread library signal handler invokes the thread signal handler immediately. If the current thread
cannot handle the signal, the thread library signal handler finds a thread that can handle the sig-
nal, adds the signal to the queue for that thread, and returns. The thread signal handlers for these
queued signals are run either at thread dispatch or at the cancellation point
Use With Standard POSIX Threads
When using standard POSIX threads, specify the spthread.h header file. The signal.h header file
can be omitted.
A multi-threaded process can use the sigaction() function to establish thread-specific actions for
synchronous signals. Each thread can have its own signal handler routine.
When you use the standard POSIX threads version of sigaction():
• The sigaction() function only modifies behavior for individual threads.
7−94 Hewlett-Packard Company 527186-023