Signal | Meaning | Trigger |
---|---|---|
SIGINT | Interrupt | Ctrl+C |
SIGQUIT | Quit | Ctrl+\ |
SIGTERM | Termination request (catchable) | kill -15 command |
SIGKILL | Forced kill (uncatchable) | kill -9 |
SIGSTOP | Pause process | kill -STOP |
SIGSEGV | Segmentation fault | Invalid memory access |
SIGABRT | Abort | abort() call |
SIGALRM | Alarm clock | alarm() or timer expired |
kill -l
: List all signal names and their numberskill -s SIGNAL <pid>
: Send the specified SIGNAL to process <pid>
kill(pid_t pid, int sig)
signal(int sig, void (*handler)(int))
sig
.SIG_ERR
on failure.signal()
typically remains in effect across multiple signals and does not revert to the default after a single execution.void handler(int sig) {
printf("Received signal %d\\n", sig);
}
signal(SIGINT, handler);
Limitations
SIGKILL
, SIGSTOP
.sigaction()
instead.sigaction(int signum, const struct sigaction *act, struct sigaction *oldact)