Signal.h

From Wikipedia, the free encyclopedia

C++ Standard Library headers
C Standard Library headers
assert.h
ctype.h
errno.h
float.h
limits.h
locale.h
math.h
setjmp.h
signal.h
stdarg.h
stddef.h
stdio.h
string.h
stdlib.h
time.h
The correct title of this article is signal.h. The initial letter is shown capitalized due to technical restrictions.

signal.h is a header file defined in the C Standard Library to specify how a program handles signals while it executes. A signal can report some exceptional behavior within the program (such as division by zero), or a signal can report some asynchronous event outside the program (such as someone striking an interactive attention key on a keyboard).

You can report any signal by calling raise. Each implementation defines what signals it generates (if any) and under what circumstances it generates them. An implementation can define signals other than the ones listed here. The standard header <signal.h> can define additional macros with names beginning with SIG to specify the values of additional signals. All such values are integer constant expressions >= 0.

You can specify a signal handler for each signal. A signal handler is a function that the target environment calls when the corresponding signal occurs. The target environment suspends execution of the program until the signal handler returns or calls longjmp. For maximum portability, an asynchronous signal handler should only:

  • make calls (that succeed) to the function signal
  • assign values to objects of type volatile sig_atomic_t
  • return control to its caller

If the signal reports an error within the program (and the signal is not asynchronous), the signal handler can terminate by calling abort, exit, or longjmp.

Contents

[edit] Member functions

[edit] Member constants

[edit] Member types

[edit] References