# Unix Signal

URL: https://softwaredictionary.org/terms/unix-signal
Category: Operating Systems
Last updated: 2026-09-30
In Turkish: sinyal
Pronunciation: YOO-niks SIG-nul

In short: A Unix signal is a short asynchronous notification the kernel delivers to a process to report an event, such as a stop request, an error, or an expired timer.

## What is a Unix signal?

A Unix signal is a simple form of communication on Unix-like systems such as Linux, macOS, and the BSDs. Each signal is a numbered event with a name: `SIGINT` is sent when you press Ctrl+C, `SIGTERM` politely asks a process to terminate, `SIGKILL` forces it to stop, `SIGHUP` reports that the terminal closed and is often used to reload configuration, `SIGSEGV` reports an invalid memory access, and `SIGCHLD` tells a parent that a child process has exited.

Signals can be sent by the kernel when something happens, by the terminal when you press certain keys, or by another process through the `kill` system call or command. When a signal arrives, the process's normal flow is interrupted and one of three things happens: the default action runs, such as terminating the process, the signal is ignored, or a custom handler function runs. `SIGKILL` and `SIGSTOP` can never be caught or ignored. Because a handler can run at almost any moment, it should do very little, such as setting a flag that the main program checks.

A signal is like a tap on the shoulder: the message is tiny, only which tap it was, but it makes someone stop what they are doing and respond. Signals matter for graceful shutdown. Container platforms send `SIGTERM`, wait for a grace period of 30 seconds by default in Kubernetes, and then send `SIGKILL`, so servers should catch `SIGTERM`, stop accepting new requests, finish the ones in flight, and exit cleanly.

Signals are often confused with hardware interrupts. An interrupt is delivered to the CPU and handled by the kernel, while a signal is delivered by the kernel to a user process, which is why signals are sometimes called software interrupts for processes. The `kill` command is also misleadingly named: it can send any signal and sends `SIGTERM` by default. Windows does not use Unix signals and has its own mechanisms, although its C runtime emulates a few of them.

## Key takeaways

- A signal is a small, asynchronous notification delivered to a process.
- Common signals include `SIGINT`, `SIGTERM`, `SIGKILL`, and `SIGHUP`.
- A process can use the default action, ignore a signal, or run a handler.
- `SIGKILL` and `SIGSTOP` cannot be caught or ignored.
- Handling `SIGTERM` enables graceful shutdown in containers and services.

## Example: Handling signals in a Bash script

```bash
#!/usr/bin/env bash
# Run cleanup when the script gets SIGINT (Ctrl+C) or SIGTERM
cleanup() { echo "Cleaning up..."; rm -f /tmp/myjob.lock; exit 0; }
trap cleanup INT TERM

touch /tmp/myjob.lock
sleep 300 &
wait $!  # waiting this way lets the trap run right away

# From another terminal:
#   kill -TERM <pid>   polite request to stop (the default signal)
#   kill -KILL <pid>   forced stop that cannot be caught or ignored
```

## Frequently asked questions

**What is the difference between SIGTERM and SIGKILL?**

`SIGTERM` asks a process to stop and gives it a chance to clean up, and it can be caught or ignored. `SIGKILL` makes the kernel stop the process immediately, with no chance to clean up.

**What happens when I press Ctrl+C in a terminal?**

The terminal sends `SIGINT` to the foreground process. By default that terminates the program, but programs can catch it, for example to save work or ask for confirmation first.

**Does Windows have Unix signals?**

Not natively. Windows uses its own mechanisms, such as console control events for Ctrl+C, although its C runtime supports a handful of signals like `SIGINT` for compatibility.

---

Software Dictionary: https://softwaredictionary.org/ · https://softwaredictionary.org/llms.txt
