Index of Section 2 Manual Pages
| Interix / SUA | signal.2 | Interix / SUA |
signal(2) signal(2)
signal()
NAME
signal() - specify signal handling (C Standard version)
SYNOPSIS
#include
void (*signal (int sig, void (*func)(int)))(int)
DESCRIPTION
The signal(2) call allows a process to catch, ignore, or to generate an
interrupt on receiving a signal. (The exceptions are SIG_KILL and
SIG_STOP, which cannot be caught or ignored.) The recommended call instead
of signal(2) is the POSIX sigaction(2) call, which is slightly more
robust.
The sig is a signal number (possible values are listed below or in the
file ).
The func argument is either a function to catch and handle the signal or
one of these macros:
SIG_DFL
Set the signal to the default action (listed below).
SIG_IGN
Ignore the signal and discard pending instances. If SIG_IGN is not
used, further occurrences of the signal are automatically blocked and
func is called.
Signals allow the manipulation of a process from outside its domain as
well as allowing the process to manipulate itself or copies of itself
(children). There are two general types of signals: those that cause
termination of a process and those that do not. Signals which cause
termination of a program might result from an irrecoverable error or might
be the result of a user at a terminal typing the 'interrupt' character.
For example, signals are used when a process is stopped to access the
process's control terminal while in the background. Signals are optionally
generated when a process resumes after being stopped, when the status of
child processes changes, or when input is ready at the control terminal.
Most signals result in the termination of the process receiving them if no
action is taken; some signals instead cause the process receiving them to
be stopped, or are simply discarded if the process has not requested
otherwise.
For a list of signals defined in the file , see the sigaction(2)
reference page. The signal(2) function cannot be used to set a signal
handler for the SIGCANCEL signal, which is reserved for internal use only.
The handled signal is unblocked with the function returns and the process
continues from where it left off when the signal occurred.
When a process which has installed signal handlers forks, the child
process inherits the signals. All caught signals may be reset to their
default action by a call to the execve(2) function; ignored signals remain
ignored.
RETURN VALUES
On success, signal(2) returns the previous action. Otherwise, it returns -
1 and sets errno to indicate the error.
ERRORS
The signal(2) call will fail and no action will take place if one of the
following occur:
[EINVAL]
Sig is not a valid signal number.
[EINVAL]
An attempt is made to ignore or supply a handler for SIGKILL or
SIGSTOP.
SEE ALSO
kill(1)
kill(2)
sigaction(2)
sigprocmask(2)
sigsuspend(2)
setjmp(3)
USAGE NOTES
The signal function is thread safe.
The signal function is async-signal safe.