Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ sigaction(2) — OSF/1 3.0 αXP

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

acct(2)

exit(2)

kill(2)

pause(3)

ptrace(2)

setjmp(3)

sigblock(2)

sigpause(3)

sigprocmask(2)

sigstack(2)

sigsuspend(2)

sigvec(2)

umask(2)

wait(2)

kill(1)

signal(4)

sigaction(2)  —  System Calls

NAME

sigaction − Specifies the action to take upon delivery of a signal

SYNOPSIS

#include <signal.h>
int sigaction (
int signal,
const struct sigaction ∗action,
struct sigaction ∗o_action );

PARAMETERS

signalDefines the signal. 

actionPoints to a sigaction structure that describes the action to be taken upon receipt of the signal specified by the signal parameter. 

o_actionPoints to a sigaction structure.  When the sigaction function returns from a call, the action previously attached to the specified signal is stored in this structure. 

DESCRIPTION

When a process requests the sigaction function, the process can both examine or specify what action is to be performed when the specified signal is delivered.  The parameters determine the behavior of the sigaction function as follows:

       •Specifying the signal parameter identifies the signal that is to be affected. 

       •Specifying the action parameter, if not null, points to a sigaction structure that defines what action is to be performed when the signal is received.  If the action parameter is null, signal handling remains unchanged; thus the call can be used to inquire about the current handling of the signal. 

       •Specifying the o_action parameter, if not null, points to a sigaction structure that contains the action previously attached to the specified signal. 

The sigaction structure consists of the following members:

void     (∗sa_handler)();
sigset_t   sa_mask;
int        sa_flags;

The members are defined as follows:

sa_handlerThis field can contain a value of SIG_DFL or SIG_IGN, or it can point to a function.  A SIG_DFL value specifies the default action is to be taken when the signal is delivered.  A value of SIG_IGN specifies that the signal has no effect on the receiving process. A pointer to a function requests that the signal be caught; that is, the signal should cause the function to be called. These actions are more fully described in the <signal.h> file. 

sa_maskThis field can request that individual signals, in addition to those in the process signal mask, are blocked from being delivered while the signal handler function specified by the sa_handler field is executing. 

sa_flagsThis field can set the following flags to enable further control over the actions taken when a signal is delivered:

SA_ONSTACK
Setting this bit causes the system to run the signal-catching function on the signal stack specified by the sigaltstack(2) and sigstack(2) functions.  If this bit is not set, the function runs on the stack of the process to which the signal is delivered. 

SA_RESETHAND
Setting this bit causes the signal to be reset to SIG_DFL. Note that SIGILL, SIGTRAP, and SIGPWR cannot be automatically reset.

SA_NODEFER
Setting this bit causes the signal not to be blocked automatically by the kernel as it is being caught.

SA_RESTART
Setting this bit enables a function that has been interrupted by the execution of this signal’s handler to be restarted transparently by the system.  The affected functions include wait, and the the read and write functions on a slow device (such as a terminal, but not a regular file). If this bit is not set and one of the previously mentioned functions is interrupted by a signal which is caught, the function returns the value -1 and sets errno to indicate error. 

SA_SIGINFO
If this bit is set and the signal is caught, the argument defined by the signal parameter and two additional arguments are passed to the signal catching function.  Should the second argument not be equal to NULL, it points to a siginfo_t structure that contains the reason the signal was generated.  Under libsys5, the third argument points to a ucontext_t structure that contains the receiving process’s context where it was interrupted by the signal.  Under libc, the third argument points to a sigcontext structure containing context information in a different format.  See siginfo(5), ucontext(5), and <sys/signal.h> for more information. 

If this bit is cleared and the signal is caught, the argument specified by the signal parameter is passed as the only argument to the signal catching function.  Two additional arguments are also available.  The second argument provides an exception-specific code defined in <sys/signal.h>; this value is always zero (0) for nonexception signals.  The third argument is a pointer to a sigcontext structure. 

SA_NOCLDWAIT
If this bit is set and the signal parameter is equal to SIGCHLD, zombie processes are not created by the system when the child process of the calling process exits.  If the wait function is subsequently issued by the calling process, it blocks until all of its child processes terminate.  It then returns a value of -1 and errno is set to ECHLD to indicate the error. 

SA_NOCLDSTOP
If this bit is set and the signal parameter is equal to SIGCHLD, and a chld process of the calling process stops, a SIGCHLD signal is sent to the calling process if, and only if SA_NOCLDSTOP is not set for SIGCHLD. 

The signal parameter can be any one of the signal values defined in the signal.h header file, except SIGKILL. 

NOTES

In a multi-threaded environment, the sigaction function should only be used for the synchronous signals. 

The sigvec and signal functions are provided for compatibility to old UNIX systems; their function is a subset of that available with the sigaction function. 

AES Support Level:
Full use

RETURN VALUES

Upon successful completion of the sigaction function, a value of zero (0) is returned. If the sigaction function fails, a value of -1 is returned and errno is set to indicate the error. 

ERRORS

If the sigaction function fails, no new signal handler is installed and errno may be set to one of the following values:

[EFAULT]The action or o_action parameter points to a location outside of the allocated address space of the process. 

[EINVAL]The signal parameter is not a valid signal number. 

[EINVAL]An attempt was made to ignore or supply a handler for the SIGKILL, SIGSTOP, and SIGCONT signals. 

RELATED INFORMATION

Functions: acct(2), exit(2), kill(2), pause(3), ptrace(2), setjmp(3), sigblock(2), sigpause(3), sigprocmask(2), sigstack(2), sigsuspend(2), sigvec(2), umask(2), wait(2). 

Commands: kill(1). 

Files: signal(4). 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026