signal(5) signal(5)
NAME
signal - base signals
SYNOPSIS
#include <signal.h>
DESCRIPTION
A signal is an asynchronous notification of an event. A signal is said
to be generated for (or sent to) a process when the event associated
with that signal first occurs. Examples of such events include
hardware faults, timer expiration and terminal activity, as well as
the invocation of the kill() or sigsend() system calls. In some cir-
cumstances, the same event generates signals for multiple processes. A
process may request a detailed notification of the source of the sig-
nal and the reason why it was generated [see siginfo(5)].
Each process may specify a system action to be taken in response to
each signal sent to it, called the signal's disposition. The set of
system signal actions for a process is initialized from that of its
parent. Once an action is installed for a specific signal, it usually
remains installed until another disposition is explicitly requested by
a call to either sigaction(), signal() or sigset(), or until the pro-
cess execs [see sigaction(2) and signal(2)]. When a process exec, all
signals whose disposition has been set to catch the signal will be set
to SIGDFL. Alternatively, a process may request that the system
automatically reset the disposition of a signal to SIGDFL after it
has been caught [see sigaction(2) and signal(2)].
A signal is said to be delivered to a process when the appropriate
action for the process and signal is taken. During the time between
the generation of a signal and its delivery, the signal is said to be
pending [see sigpending(2)]. Ordinarily, this interval cannot be
detected by an application. However, a signal can be blocked from
delivery to a process [see signal(2) and sigprocmask(2)]. If the
action associated with a blocked signal is anything other than to
ignore the signal, and if that signal is generated for the process,
the signal remains pending until either it is unblocked or the
signal's disposition requests that the signal be ignored. If the sig-
nal disposition of a blocked signal requests that the signal be
ignored, and if that signal is generated for the process, the signal
is discarded immediately upon generation.
Each process has a signal mask that defines the set of signals
currently blocked from delivery to it [see sigprocmask(2)]. The signal
mask for a process is initialized from that of its parent.
The determination of which action is taken in response to a signal is
made at the time the signal is delivered, allowing for any changes
since the time of generation. This determination is independent of the
means by which the signal was originally generated.
Page 1 Reliant UNIX 5.44 Printed 11/98
signal(5) signal(5)
signal.h declares constants referring to system signals:
____________________________________________________________________
| Name | Value| Default| Event |
|__________|_______|_________|______________________________________|
| SIGHUP | 1 | Exit | Hangup [see termio(7)] |
| SIGINT | 2 | Exit | Interrupt [see termio(7)] |
| SIGQUIT | 3 | Core | Quit [see termio(7)] |
| SIGILL | 4 | Core | Illegal instruction |
| SIGTRAP | 5 | Core | Trace/breakpoint trap |
| SIGIOT | 6 | Core | Abort |
| SIGABRT | 6 | Core | Abort |
| SIGEMT | 7 | Core | Emulation trap |
| SIGFPE | 8 | Core | Arithmetic exception |
| SIGKILL | 9 | Exit | Killed |
| SIGBUS | 10 | Core | Bus error |
| SIGSEGV | 11 | Core | Segmentation fault |
| SIGSYS | 12 | Core | Bad system call |
| SIGPIPE | 13 | Exit | Broken pipe |
| SIGALRM | 14 | Exit | Alarm clock |
| SIGTERM | 15 | Exit | Terminated |
| SIGUSR1 | 16 | Exit | User signal 1 |
| SIGUSR2 | 17 | Exit | User signal 2 |
| SIGCHLD | 18 | Ignore | Child status |
| SIGPWR | 19 | Ignore | Power fail/restart |
| SIGWINCH | 20 | Ignore | Window size change |
| SIGURG | 21 | Ignore | Urgent socket condition |
| SIGIO | 22 | Ignore | Socket I/O possible (SIGPOLL alias) |
| SIGPOLL | 22 | Exit | Pollable event occurred |
| SIGSTOP | 23 | Stop | Stopped (signal) |
| SIGTSTP | 24 | Stop | Stopped (user) [see termio(7)] |
| SIGCONT | 25 | Ignore | Continued |
| SIGTTIN | 26 | Stop | Stopped (tty input) [see termio(7)] |
| SIGTTOU | 27 | Stop | Stopped (tty output) [see termio(7)]|
| SIGVTALRM| 28 | Exit | Virtual timer expired |
| SIGPROF | 29 | Exit | Profiling timer expired |
| SIGXCPU | 30 | Core | CPU time limit exceeded [see |
| | | | getrlimit(2)] |
| SIGXFSZ | 31 | Core | File size limit exceeded [see |
| | | | getrlimit(2)] |
|__________|_______|_________|______________________________________|
Using the signal(), sigset() or sigaction() system call, a process may
specify one of three dispositions for a signal: take the default
action for the signal, ignore the signal, or catch the signal.
Page 2 Reliant UNIX 5.44 Printed 11/98
signal(5) signal(5)
signal.h contains the definitions of the following symbolic constants,
each of which expands to an expression of the type void(*)(int), and
whose value matches no declarable function:
SIGDFL Default signal handling.
SIGERR Return value from signal() in case of error.
SIGIGN Signal is ignored.
In addition, the following data types are defined in signal.h:
sigatomict Integral type of an object that can be accessed even
in the presence of an asynchronous interrupt.
sigsett Integral or structure type of an object used to rep-
resent sets of signals.
pidt As described in <sys/types.h> [see types(5)].
signal.h provides the declaration of struct sigaction including at
least the following elements.
Only valid if generated with "c89":
void(*sahandler)(int)
Action on receipt of a signal
sigsett samask Set of signals to be blocked during execution of a
signal handling function
int saflags Special flags
void (*)(int, siginfot *, void *) sasigaction
Pointer to signal handler function or one of the
macros SIGIGN or SIGDFL.
Only valid if generated with "cc":
void (*sahandler)();
sigsett samask;
int saflags;
The storage occupied by sahandler and sasigaction may overlap, and a
portable program must not use both simultaneously.
Page 3 Reliant UNIX 5.44 Printed 11/98
signal(5) signal(5)
The following constants are declared in signal.h:
SANOCLDSTOP Do not generate SIGCHILD when child processes stop.
SIGBLOCK The resulting set is the union of the current set
and the complement of the signal set pointed to by
the argument set.
SIGUNBLOCK The resulting set is the intersection of the current
set and the complement of the signal set pointed to
by the argument set.
SIGSETMASK The resulting set is the signal set pointed to by
set.
SAONSTACK Causes signal delivery to occur on an alternate
stack.
SARESETHAND Causes signal dispositions to be set to SIGDFL on
entry to signal handlers.
SARESTART Causes certain functions to become restartable.
SASIGINFO Causes extra information to be passed to signal
handlers at the time of receipt of a signal.
SANOCLDWAIT Causes implementations not to create zombie
processes on child death.
SANODEFER Causes signal not to be automatically blocked on
entry to signal handler.
SSONSTACK Process is executing on an alternate signal stack.
SSDISABLE Alternate signal stack is disabled.
MINSIGSTKSZ Minimum stack size for a signal handler.
SIGSTKSZ Default size in bytes for the alternate signal
stack.
The ucontextt structure is defined through typedef as described in
<ucontext.h> [see ucontext(5)].
The signal.h header defines the stackt type as a structure that
includes at least the following members:
void *sssp Stack base or pointer.
sizet sssize Stack size.
int ssflags Flags.
Page 4 Reliant UNIX 5.44 Printed 11/98
signal(5) signal(5)
The signal.h header defines the sigstack structure that includes at
least the following members:
int ssonstack Non-zero when signal stack is in use.
void *sssp Signal stack pointer.
The signal.h header defines the siginfot type as a structure that
includes at least the following members:
int sisigno Signal number.
int sierrno if non-zero, an errno value associated with this
signal, as defined in <errno.h>
int sicode Signal code.
pidt sipid Sending process ID.
uidt siuid Real user ID of sending process.
void *siaddr Address of faulting instruction.
int sistatus Exit value or signal.
long siband Band event for SIGPOLL.
The macros specified in the Code column of the following table are
defined for use as values of sicode that are signal-specific reasons
why the signal was generated.
Signal Code Reason
______________________________________________________________________
SIGILL ILLILLOPC illegal opcode
ILLILLOPN illegal operand
ILLILLADR illegal addressing mode
ILLILLTRP illegal trap
ILLPRVOPC privileged opcode
ILLPRVREG privileged register
ILLCOPROC coprocessor error
ILLBADSTK internal stack error
______________________________________________________________________
SIGFPE FPEINTDIV integer divide by zero
FPEINTOVF integer overflow
FPEFLTDIV floating point divide by zero
FPEFLTOVF floating point overflow
FPEFLTUND floating point underflow
FPEFLTRES floating point inexact result
FPEFLTINV invalid floating point operation
FPEFLTSUB subscript out of range
Page 5 Reliant UNIX 5.44 Printed 11/98
signal(5) signal(5)
______________________________________________________________________
SIGSEGV SEGVMAPERR address not mapped to object
SEGVACCERR invalid permissions for mapped object
______________________________________________________________________
SIGBUS BUSADRALN invalid address alignment
BUSADRERR non-existent physical address
BUSOBJERR object specific hardware error
______________________________________________________________________
SIGTRAP TRAPBRKPT process breakpoint
TRAPTRACE process trace trap
______________________________________________________________________
SIGCHLD CLDEXITED child has exited
CLDKILLED child has terminated abnormally and did not
create a core file
CLDDUMPED child has terminated abnormally and created a
core file
CLDKILLED child was killed
CLDDUMPED child has terminated abnormally
CLDTRAPPED traced child has trapped
CLDSTOPPED child has stopped
CLDCONTINUED stopped child has continued
______________________________________________________________________
SIGPOLL POLLIN data input available
POLLOUT output buffers available
POLLMSG input message available
POLLERR I/O error
POLLPRI high priority input available
POLLHUP device disconnected
Implementations may support additional sicode values not included in
this list, may generate values included in this list under cir-
cumstances other than those described in this list, and may contain
extensions or limitations that prevent some values from being gen-
erated. Implementations will not generate a different value from the
ones described in this list for circumstances described in this list.
In addition, the following signal-specific information will be avail-
able:
Signal Member Value
______________________________________________________________________
SIGILL void * siaddr address of faulting instruction
SIGFPE
______________________________________________________________________
SIGSEGV void * siaddr address of faulting memory reference
SIGBUS
______________________________________________________________________
Page 6 Reliant UNIX 5.44 Printed 11/98
signal(5) signal(5)
SIGCHLD pidt sipid child process ID
int sistatus exit value or signal
uidt siuid real user ID of the process that sent the
signal
______________________________________________________________________
SIGPOLL long siband band event for POLLIN, POLLOUT, or
POLLMSG
For some implementations, the value of siaddr may be inaccurate.
The following functions are declared in signal.h and may also be
defined as macros:
void (*bsdsignal(int sig, void (*func)(int)))(int);
int kill(pidt pid, int sig);
int killpg(pidt pgrp, int sig);
int raise(int sig);
int sigaction(int sig, const struct sigaction *act,
int sigaction(int sig, const struct sigaction *act,
struct sigaction *oact);
int sigaddset(sigsett *set, int signo);
int sigaltstack(const stackt *ss, stackt *oss);
int sigdelset(sigsett *set, int signo);
int sigemptyset(sigsett *set);
int sigfillset(sigsett *set);
int sighold(int sig);
int sigignore(int sig);
int siginterrupt(int sig, int flag);
int sigismember(const sigsett *set, int);
void (*signal(int sig, void (*func) (int))) (int);
int sigpause(int sig);
int sigpending(sigsett *set);
int sigprocmask(int how, const sigsett *set, sigsett *oset);
int sigrelse(int sig); void *sigset(int sig, void
(*disp)(int)))(int); int sigstack(struct sigstack *ss,
struct sigstack *oss);
int sigsuspend(const sigsett *sigmask);
Default Action
A disposition of SIGDFL specifies the default action. The default
action for each signal is listed in the table above and is selected
from the following:
Exit When it gets the signal, the receiving process is to be ter-
minated with all the consequences outlined in exit(2).
Core When it gets the signal, the receiving process is to be ter-
minated with all the consequences outlined in exit(2). In
addition, a core image of the process is constructed in the
current working directory.
Page 7 Reliant UNIX 5.44 Printed 11/98
signal(5) signal(5)
Stop When it gets the signal, the receiving process is to stop.
Ignore When it gets the signal, the receiving process is to ignore
it. This is identical to setting the disposition to SIGIGN.
Catch Signal
A disposition that is a function address specifies that, when it gets
the signal, the receiving process is to execute the signal handler at
the specified address. Normally, the signal handler is passed the sig-
nal number as its only argument; if the disposition was set with the
sigaction() function however, additional arguments may be requested
[see sigaction(2)]. When the signal handler returns, the receiving
process resumes execution at the point it was interrupted, unless the
signal handler makes other arrangements. If an invalid function
address is specified, results are undefined.
If the disposition has been set with the sigset() or sigaction() func-
tion, the signal is automatically blocked by the system while the sig-
nal catcher is executing. If a longjmp() [see setjmp(3C)] is used to
leave the signal catcher, then the signal must be explicitly unblocked
by the user [see signal(2) and sigprocmask(2)].
If execution of the signal handler interrupts a blocked system call,
the handler is executed and the interrupted system call returns a -1
to the calling process with errno set to EINTR. However, if the
SARESTART flag is set the system call will be transparently re-
started.
NOTES
The dispositions of the SIGKILL and SIGSTOP signals cannot be altered
from their default values. The system generates an error if this is
attempted.
The SIGKILL and SIGSTOP signals cannot be blocked. The system silently
enforces this restriction.
Whenever a process receives a SIGCONT signal, regardless of its dispo-
sition, any pending SIGSTOP, SIGTSTP, SIGTTIN, and SIGTTOU signals is
discarded. In addition, if the process was stopped, it is continued.
SIGPOLL is issued when a file descriptor corresponding to a STREAMS
file has a "selectable" event pending. A process must specifically
request that this signal be sent using the ISETSIG ioctl call. Other-
wise, the process will never receive SIGPOLL.
If the disposition of the SIGCHLD signal has been set with signal() or
sigset(), or with sigaction() and the SANOCLDSTOP flag has been
specified, it will only be sent to the calling process when its chil-
dren exit; otherwise, it will also be sent if the calling process'
children were stopped or continued due to job control.
Page 8 Reliant UNIX 5.44 Printed 11/98
signal(5) signal(5)
The name SIGCLD is also defined in this header file and identifies the
same signal as SIGCHLD. SIGCLD is provided for backward compatibility,
new applications should use SIGCHLD.
The disposition of signals that are inherited as SIGIGN should not be
changed.
SEE ALSO
alarm(2), bsdsignal(2), exit(2), getrlimit(2), introprm2(2),
ioctl(2), kill(2), pause(2), sigaction(2), sigaltstack(2), signal(2),
sigprocmask(2), sigsend(2), sigsuspend(2), wait(2), waitid(2),
sigsetops(3C), errno(5), siginfo(5), types(5), ucontext(5).
Page 9 Reliant UNIX 5.44 Printed 11/98