www.LinuxHowtos.org
SIGNAL
Section: POSIX Programmer's Manual (3P)Updated: 2013
Index Return to Main Contents
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 managementSYNOPSIS
#include <signal.h> void (*signal(int sig, void (*func)(int)))(int);
DESCRIPTION
The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the requirements described here and the ISO C standard is unintentional. This volume of POSIX.1-2008 defers to the ISO C standard. 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);
-
(*func)(sig);
- *
- The process calling abort(), raise(), kill(), pthread_kill(), or sigqueue() to generate a signal that is not blocked
- *
-
A pending signal being unblocked and being delivered before the call
that unblocked it returns
the behavior is undefined if the signal handler refers to any object
other than
errno
with static storage duration other than by assigning a value to an
object declared as
volatile sig_atomic_t,
or if the signal handler calls any function defined in this standard
other than
one of the functions listed in
Section 2.4, Signal Concepts.
At program start-up, the equivalent of:
-
signal(sig, SIG_IGN);
-
signal(sig, SIG_DFL);
-
RETURN VALUE
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.ERRORS
The signal() function shall fail if:- EINVAL
- The sig argument is not a valid signal number or an attempt is made to catch a signal that cannot be caught or ignore a signal that cannot be ignored. The signal() function may fail if:
- EINVAL
- An attempt was made to set the action to SIG_DFL for a signal that cannot be caught or ignored (or both).
The following sections are informative.
EXAMPLES
None.APPLICATION USAGE
The sigaction() function provides a more comprehensive and reliable mechanism for controlling signals; new applications should use sigaction() rather than signal().RATIONALE
None.FUTURE DIRECTIONS
None.SEE ALSO
Section 2.4, Signal Concepts, exec, pause(), raise(), sigaction(), sigsuspend(), waitid() The Base Definitions volume of POSIX.1-2008, <signal.h>COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, Copyright (C) 2013 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. (This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) 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.unix.org/online.html .Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .