SIGPIPE Signal Explained (Signal 13)
What the Linux SIGPIPE signal does and when it's used.
Published October 24, 2026
SIGPIPE (signal 13) is sent when a process writes to a pipe or socket whose reader has closed, for example when head exits before the producer finishes.
What it does
Default action: Terminate. It can be caught with a signal handler.
Typically sent by: the kernel on writing to a closed pipe/socket. List all signals with kill -l.
Signal number and delivery
kill -l | grep SIGPIPE
13) SIGPIPE
kill -13 1234 # or kill -PIPE 1234
(signal delivered to process 1234)
Practical examples
Send it from the shell
kill -13 <PID>
kill -SIGPIPE <PID>
pkill -13 nginxHandle it in a script
trap 'echo got SIGPIPE; cleanup; exit' SIGPIPE
while true; do sleep 1; doneHandle it in code
import signal, sys
def handler(sig, frame):
print('received', sig)
sys.exit(0)
signal.signal(signal.SIGPIPE, handler)Common mistakes
- Using kill -9 before trying SIGTERM.
- Forgetting to find the right PID (ps aux | grep, pgrep).
- Not handling signals in long-running services.
Key takeaways
- SIGPIPE is signal 13.
- Default: Terminate.
- Use kill -l to list all signals.
FAQ
Why does yes | head stop?
head exits, the next write by yes triggers SIGPIPE and ends it.
How do I list all signals?
Run kill -l.