Csignal
lastmod 2022-11-01created 2015-09-3021 edits
For signal handling in C, see C signal handling.
In the standard library, signal processing defines how a program handles various signals while it is running. A signal can report some exceptional behavior within the program (such as division by zero), or an asynchronous event outside the program (such as a key press on the keyboard).
Define
// Defined in header <csignal>
#define SIGINT 2 /* Interactive attention */
#define SIGILL 4 /* Illegal instruction */
#define SIGFPE 8 /* Floating point error */
#define SIGSEGV 11 /* Segmentation violation */
#define SIGTERM 15 /* Termination request */
#define SIGBREAK 21 /* Control-break */
#define SIGABRT 22 /* Abnormal termination (abort) */
Each of the above macro constants expands to an integer constant expression with distinct values, which represent different signals sent to the program.
| Constant | Explanation |
| SIGTERM | termination request, sent to the program |
| invalid memory access (segmentation fault) | |
| SIGINT | external interrupt, usually initiated by the user |
| SIGILL | invalid program image, such as invalid instruction |
| SIGABRT | abnormal termination condition, as is e.g. initiated by std::abort() |
| SIGFPE | erroneous arithmetic operation such as divide by zero |
SIGKILL vs SIGTERM
See C signal handling#SIGKILL vs SIGTERM for details.
See also
- std::atomic_signal_fence
- std::memory_order
- See
/usr/include/bits/signum.h - kill: sample code:
kill -l
Favorite site
- cppreference.com - std::signal
- signal(7) - Linux manual page
- [Recommended] POSIX signal.h
- SIGTERM, SIGSEGV, SIGINT, SIGILL, SIGABRT, SIGFPE
- [Recommended] C/C++ signal handling
- Stackoverflow: User defined signal 1
- [Recommended] C Language_System Programming : Signals 1
- C/C++ signal handling 2