In operating system design, signals are a form of IPC that approximate the behaviour of hardware-level interrupts. They work by having the kernel send a number to the program indicating the type of signal. Signal handlers function similarly to interrupt handlers.

The kernel has default handlers for each signal, which may ignore the signal or terminate the process. If the default handler occurs, the exit code will be 128 + the signal number. Just like interrupts, the process may be interrupted at any point, and may resume after the signal handler exits.

For example, some common signals include:

  • SIGINT (2): keyboard interrupt (Ctrl + C).
  • SIGKILL (9): terminate immediately. Unignorable signal.
  • SIGSEGV (11): segfault.
  • SIGTERM (15): terminate.

The kill <pid> utility sends SIGTERM to a given process ID. The -9 flag tells kill to send SIGKILL instead. kill uses permission checks to ensure you have “ownership” over a process (which can be circumvented with sudo).

See also