Csignal
C 의 신호 처리와 관련된 내용은 C signal handling 항목 참조.
표준 라이브러리에서 시그널 처리(signal processing)는 프로그램이 실행 중에 다양한 시그널들을 어떻게 처리하는지를 정의한다. 시그널은 프로그램 내에서 몇몇 예외적인 행위(0으로 나누기 같은)를 보고하거나, 프로그램 외부의 비동기적 이벤트(키보드 키를 누르기 같은)를 보고할 수 있다.
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
C signal handling#SIGKILL vs SIGTERM 항목 참조.
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
- [추천] POSIX signal.h
- SIGTERM, SIGSEGV, SIGINT, SIGILL, SIGABRT, SIGFPE
- [추천] C/C++ signal handling
- Stackoverflow: User defined signal 1
- [추천] C언어_시스템프로그래밍 : 시그널 1
- C/C++ signal handling 2