Skip to content
The Signal Belfry

/static/campanario/en/sino/sigpipe/

Menu

SIG-020 · Resources

SIGPIPE

A write into a pipe with nobody on the other end — which is why head ends the conversation.

When a pipe's reader closes and the writer insists, the kernel rings this bell at the writer. It is the secret of grep pattern huge.log | head finishing early: head prints ten lines and exits; on the next write, the producer dies silently — without sweeping the rest of the file for nothing.

The silence is deliberate: pipelines limit themselves without anyone programming a thing. But servers writing to sockets don't want to die because a client hung up — so they ignore the signal and handle the EPIPE error instead.

$ yes | head -3
y
y
y
$
(yes would run forever; head closed the pipe and the bell silenced it)
The whole pipeline stops when the last one shuts the door.