signal.2 (2010 09)

s
signal(2) signal(2)
NAME
signal(), sigset(), sighold(), sigrelse(), sigignore(), sigpause() - signal management
SYNOPSIS
#include <signal.h>
void (*signal(int sig, void (*func)(int)))(int);
int sighold(int sig);
int sigignore(int sig);
int sigpause(int sig);
int sigrelse(int sig);
void (*sigset(int sig, void (*disp)(int)))(int);
DESCRIPTION
The functions described in this reference page provide simplified signal management:
The
signal() function chooses one of three ways in which receipt of the signal number sig is to be
subsequently handled.
The
sigset() function is used to modify signal dispositions.
The
sighold() function adds sig to the calling process’ signal mask.
The
sigrelse() function removes sig from the calling process signal mask.
The
sigignore() function sets the disposition of sig to SIG_IGN.
The
sigpause() function removes sig from the calling process’ signal mask and suspends the calling
process until a signal is received.
The system defines a set of signals that can be delivered to a process. The set of signals is defined in sig-
nal(5), along with the meaning and side effects of each signal. An alternate mechanism for handling
these signals is defined here. The facilities described here should not be used in conjunction with the
other facilities described under signal(2), sigvector (2), sigblock (2), sigsetmask (2), sigpause (3C), and sig-
space (2).
The
signal() function chooses one of three ways in which receipt of the signal number sig is to be sub-
sequently handled. If the value of func is
SIG_DFL, default handling for that signal will occur. If the
value of func is SIG_IGN, the signal will be ignored. Otherwise, func must point to a function to be
called when that signal occurs. Such a function is called a signal handler.
When a signal occurs, if func points to a function, first the equivalent of:
signal(sig, SIG_DFL);
is executed or an implementation-dependent blocking of the signal is performed. (If the value of sig is
SIGILL, whether the reset to SIG_DFL occurs is implementation-dependent.) Next the equivalent of:
(*func)(sig);
is executed. The func function may terminate by executing a return statement or by calling abort(),
exit(),orlongjmp().Iffunc() executes a return statement and the value of sig was SIGFPE or
any other implementation-dependent value corresponding to a computational exception, the behavior is
undefined. Otherwise, the program will resume execution at the point it was interrupted.
If the signal occurs other than as the result of calling
abort(), kill(), raise(),
pthread_kill(),orsigqueue(), the behavior is undefined if the signal handler calls any function
in the standard library other than one of the functions listed on the thread_safety(5) manpage or refers to
any object with static storage duration other than by assigning a value to a static storage duration vari-
able of type volatile sig_atomic_t . Furthermore, if such a call fails, the value of errno is indeterminate.
At program startup, the equivalent of:
signal(sig, SIG_IGN);
is executed for some signals, and the equivalent of:
signal(sig, SIG_DFL);
HP-UX 11i Version 3: September 2010 1 Hewlett-Packard Company 1

Summary of content (4 pages)