signal (3p) - Linux Manuals
signal: signal management
PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.NAME
signal - signal management
SYNOPSIS
#include <signal.h>
void (*signal(int sig, void (*func)(int)))(int);
DESCRIPTION
Use of this function is unspecified in a multi-threaded process.
The signal() function chooses one of three ways in which receipt of the signal number sig is to be subsequently handled. If the value of func is SIG_DFL, default handling for that signal shall occur. If the value of func is SIG_IGN, the signal shall be ignored. Otherwise, the application shall ensure that func points to a function to be called when that signal occurs. An invocation of such a function because of a signal, or (recursively) of any further functions called by that invocation (other than functions in the standard library), is called a "signal handler".
When a signal occurs, and func points to a function, it is implementation-defined whether the equivalent of a:
-
signal(sig, SIG_DFL);
is executed or the implementation prevents some implementation-defined set of signals (at least including sig) from occurring until the current signal handling has completed. (If the value of sig is SIGILL, the implementation may alternatively define that no action is taken.) Next the equivalent of:
-
(*func)(sig);
is executed. If and when the function returns, if the value of sig was SIGFPE, SIGILL, or SIGSEGV or any other implementation-defined value corresponding to a computational exception, the behavior is undefined. Otherwise, the program shall resume execution at the point it was interrupted. If the signal occurs as the result of calling the abort(), raise(), kill(), pthread_kill(), or sigqueue() function, the signal handler shall not call the raise() function.
If the signal occurs other than as the result of calling abort(),
raise(), kill(), pthread_kill(), or sigqueue(),
At program start-up, the equivalent of:
is executed for some signals, and the equivalent of:
is executed for all other signals (see exec).
If the request can be honored, signal() shall return the value
of func for the most recent call to signal()
for the specified signal sig. Otherwise, SIG_ERR shall be returned
and a positive value shall be stored in errno.
The signal() function shall fail if:
The signal() function may fail if:
The following sections are informative.
The sigaction() function provides a more comprehensive and reliable
mechanism
for controlling signals; new applications should use sigaction()
rather than
signal().
Signal Concepts, exec(), pause(), sigaction(),
sigsuspend(), waitid(), the Base Definitions volume
of IEEE Std 1003.1-2001, <signal.h>
signal(sig, SIG_IGN);
signal(sig, SIG_DFL);
RETURN VALUE
ERRORS
EXAMPLES
APPLICATION USAGE
RATIONALE
FUTURE DIRECTIONS
COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .
SEE ALSO