struct sigaction

Structure that specifies how to handle a signal

Synopsis:

The definition of struct sigaction is complicated; see <signal.h> for details.

Description:

The sigaction structure specifies how to handle a signal. You'll use this structure when you call sigaction() or SignalAction() The members include the following:

void (*sa_handler) (int signo );
The address of a signal handler or action for nonqueued signals.
void (*sa_sigaction) (int signo, siginfo_t *info, void *other);
The address of a signal handler or action for queued signals.
sigset_t sa_mask
An additional set of signals to be masked (blocked) during execution of the signal-catching function.
int sa_flags
Flags that affect the behavior of the signal:

The sa_handler and sa_sigaction members of act are implemented as a union and share common storage. They differ only in their prototypes, with sa_handler being used for POSIX 1003.1a signals, and sa_sigaction being used for POSIX 1003.1b queued realtime signals. The values stored using either name can be one of:

function
The address of a signal-catching function. See below for details.
SIG_DFL
Use the default action for the signal:
SIG_IGN
Ignore the signal. Setting SIG_IGN for a signal that's pending discards all pending signals, whether it's blocked or not. New signals are discarded. If you set the action for SIGCHLD to SIG_IGN, your process's children won't enter the zombie state, and the process won't be able to use wait() or waitpid() to wait on their deaths.

The function member of sa_handler or sa_sigaction is always invoked with the following arguments:

void handler(int signo, siginfo_t *info, void *other)

If you have an old-style signal handler of the form:

void handler(int signo)

the microkernel passes the extra arguments, but the function simply ignores them. The info argument is a pointer to a siginfo_t structure that contains details about the signal.

While in the handler, signo is masked, preventing nested signals of the same type. In addition, any signals set in the sa_mask member of act are also ORed into the mask. When the handler returns through a normal return, the previous mask is restored, and any pending and now unmasked signals are acted on. You return to the point in the program where it was interrupted. If the thread was blocked in the kernel when the interruption occurred, the kernel call returns with an EINTR (see ChannelCreate() and SyncMutexLock() for exceptions to this).


Note: It isn't safe to use floating-point operations in signal handlers.

Examples:

See sigaction().

Classification:

POSIX 1003.1

See also:

sigaction(), siginfo_t, SignalAction()

Process termination in the “Processes” chapter of the QNX Neutrino Programmer's Guide