Linux system errors
Broken Pipe
Reviewed for reference consistency: August 11, 2026
the process wrote into a pipe whose reader is already gone
What 141 Means
The 141 error on the Linux system errors indicates broken pipe — the process wrote into a pipe whose reader is already gone. This typically occurs due to a downstream stage of a pipeline exiting early (head is the canonical case) while upstream keeps writing.
Exit code 141 equals 128 + 13, SIGPIPE: a write landed on a pipe or socket whose reader had already left, and the kernel ended the writer.
How to fix 141
General informational guidance, not professional advice. Commands can affect your system or data — back up first and proceed at your own risk. FixerCode is an independent reference, not affiliated with any vendor mentioned.
See each pipeline stage's fate
After a pipeline runs, PIPESTATUS reports every stage's exit code, showing whether the producer died and the consumer succeeded.
./generate_rows | head -n 10; echo ${PIPESTATUS[@]}Make the pipeline report the real failure
With pipefail active, the pipeline's own status reflects the producer's death instead of hiding behind the consumer's success.
set -o pipefail; ./generate_rows | head -n 10
Technical Background
Exit code 141 is the producer's side of the `| head` pipeline. head grabs its ten lines, exits, and the pipe's read end closes with it. The producer, still generating rows, makes one more write — and the kernel answers with signal 13. The shell's 128+13 arithmetic turns that into the 141 printed in job summaries.
Daemons inherit the same trap through sockets. A client that disconnects mid-response leaves the server writing into a dead connection; a server that never arranged for SIGPIPE dies on the spot. C network servers therefore usually silence the signal and process write failures themselves, while higher-level runtimes arrange that opt-out by default.
The death is arguably a success story: the reader got what it wanted, the writer got told, and the kernel kept the pipeline honest. Treating 141 as an automatic failure depends on whether the truncated output was the goal or an accident.
Common Causes
- A downstream stage of a pipeline exiting early (head is the canonical case) while upstream keeps writing
- A network peer closing a socket connection while the server was mid-write
- A daemon that failed to ignore SIGPIPE writing to a client connection closed seconds earlier
Typical Scenarios
- A log generator piped into head, dying with 141 the moment head has its ten lines and exits
- A web application crashing with 141 when it wrote a response to a client that already disconnected
- A background data pump failing mid-transfer after an SSH tunnel dropped
What to Know
In pipelines, the interesting question is which stage exited and why; per-stage exit statuses answer it. In network services, the pattern of 141 deaths against client disconnects in the logs usually settles the story.
Frequently Asked Questions
Common questions about Linux 141 error
head exits after reading its line count, closing the pipe's read end. The producer's next write then breaks, the kernel raises SIGPIPE, and the shell records 141. The pipeline as a whole often still did its job.
Both numbers describe one broken-pipe event from different seats. Every write into a pipe with no reader raises SIGPIPE, and a process running on the default disposition never gets to see anything after it. A program that has opted out of that signal instead collects errno 32 from the write call and decides its own next move.
Python's runtime starts with SIGPIPE ignored, so writes to closed pipes return EPIPE and surface as exceptions. The same underlying event produces exit 141 in a C program and a traceback in Python.
Related Error Codes
Broken Pipe — a write failed because the pipe's read end had already closed
Terminated by User — the process was interrupted by a SIGINT signal
Invalid Exit Argument — script exited with an out-of-range status or terminated by a signal
Termination Request — a polite shutdown signal the process may handle before exiting
Related Errors From Other Categories
Similar error codes documented across different platforms and systems
Git paused the merge because it cannot automatically resolve overlapping changes.
Git aborted the merge to protect uncommitted changes in your working directory.
Git prevented a branch switch because it would overwrite unsaved changes in your working directory.
Git aborted the merge because it would overwrite untracked files in your working directory.