process signals

signals are how processes communicate to each other or to/from the kernel about the state of the system!

for ex - if a process wants to read from disk, the kernel will give it a signal once the disk is ready to be read by it!

read https://man7.org/linux/man-pages/man7/signal.7.html

consider signal as an interrupt to notify a process that some event has occurred!

what can a signal do?

a signal can tell a process to:

  • stop
  • pause
  • continue
  • terminate
  • reload config
  • handle exceptional events (like seg faults)

how signals work?

  • every process has a PID
  • signals are send to PID using commands or internally
  • the process receiving signal can:
    • handle it (is it has a signal handler defined in its code)
    • ignore it (for some signals)
    • use the default action (kill, stop, etc.)

sending signals

the most common way to send signal is the kill command

kill -SIGTERM 1234 # sends the SIGTERM signal to process with id 1234
 
or
 
kill -15 1234 # each signal has a number 15 = SIGTERM
SignalNumberMeaning / Default Action
SIGKILL9Immediately kills the process (cannot be caught/ignored)
SIGTERM15Politely asks process to terminate (default kill)
SIGINT2Interrupt (like pressing Ctrl + C in terminal)
SIGQUIT3Quit and dump core (like Ctrl + )
SIGHUP1Hangup – often used to reload config (e.g., daemons)
SIGSTOP19Stop process (cannot be caught/ignored)
SIGCONT18Continue a stopped process
SIGCHLD17Sent to parent when child terminates
SIGSEGV11Segmentation fault (invalid memory access)
SIGALRM14Alarm from timer expiry
sudo killall <process-name> # kill all processes started by process-name
pkill <user-name> # kill all processes started by the user
man 7 signal # get all the signals

process

202509241919