| Number | Name | Function |
|---|---|---|
| 1 | SIGHUP | Hangup detected on controlling terminal or death of controlling process |
| 2 | SIGINT | Interrupt from keyboard (Ctrl+c) |
| 3 | SIGQUIT | Quit from keyboard |
| 4 | SIGILL | Illegal instruction |
| 5 | SIGTRAP | Trace trap |
| 6 | SIGABRT | Abort signal from abort |
| 6 | SIGIOT | I/O trap |
| 7 | SIGBUS | Bus error |
| 8 | SIGFPE | Floating point exception |
| 9 | SIGKILL | Kill signal |
| 10 | SIGUSR1 | User define signal 1 |
| 11 | SIGSEGV | Invalid memory reference |
| 12 | SIGUSR2 | User define signal 2 |
| 13 | SIGPIPE | Write to pipe with no readers |
| 14 | SIGALRM | Timer signal from alarm |
| 15 | SIGTERM | Termination signal |
| 16 | SIGTKFLT | Stack fault |
| 17 | SIGCHLD | Child status has changed |
| 18 | SIGCONT | Continue after stop |
| 19 | SIGSTOP | Stop(Ctrl+z) |
| 20 | SIGTSTP | Stop signal generated from keyboard |
| 21 | SIGTTIN | Background read attempted from control terminal |
| 22 | SIGTTOU | Background write attempted to control terminal |
| 23 | SIGURG | Urgent condition present on socket |
| 24 | SIGXCPU | CPU time limit exceeded |
| 25 | SIGXFSZ | File size limit exceeded |
| 26 | SIGVTALRM | Virtual time alarm |
| 27 | SIGPROF | Profiling timer alarm |
| 28 | SIGWINCH | Window changed |
| 29 | SIGIO | I/O is possible on a descriptor |
| 29 | SIGPOLL | I/O is possible on a descriptor |
| 30 | SIGPWR | UPS power Failure |
| 31 | SIGUNUSED | Unused |
main.c
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
void handle_signal(int sig)
{
printf("User break\n");
signal(SIGINT, SIG_DFL);
}
int main(int argc, char *argv[])
{
signal(SIGINT, handle_signal);
pause();
return 0;
}
編譯、執行
$ gcc main.c -o main
$ ./main
^C User break