Error Codes Wiki

Linux errno 32 (EPIPE) — Broken Pipe

Informationalerrno

About Linux errno 32 (EPIPE)

Linux errno 32 (EPIPE) means a write was attempted on a pipe or socket whose reading end has been closed. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.

Here are the key things to understand: EPIPE — broken pipe, reader has disconnected. Also generates SIGPIPE signal (default: terminate process). Common in piped commands and network programming. Handle by ignoring SIGPIPE or checking write return values. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.

The most common reasons this occurs include: Pipe reader process terminated before writer finished. Network client disconnected while server was sending data. Head command only reads partial output then exits. Socket peer closed the connection. Identifying the root cause is the first step toward finding the right solution.

To resolve this, follow these recommended steps: For scripts: pipe output to head/tail can cause EPIPE (normal). For programs: ignore SIGPIPE signal with signal(SIGPIPE, SIG_IGN). Check write() return value for errors. Use MSG_NOSIGNAL flag with send() on sockets. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.

This article is part of our Linux Error Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.

Quick Answer

Is broken pipe an error?

In piping commands, it is normal (e.g., yes | head). In network code, it means the client disconnected.

Overview

Linux errno 32 (EPIPE) means a write was attempted on a pipe or socket whose reading end has been closed.

Key Details

  • EPIPE — broken pipe, reader has disconnected
  • Also generates SIGPIPE signal (default: terminate process)
  • Common in piped commands and network programming
  • Handle by ignoring SIGPIPE or checking write return values

Common Causes

  • Pipe reader process terminated before writer finished
  • Network client disconnected while server was sending data
  • Head command only reads partial output then exits
  • Socket peer closed the connection

Steps

  1. 1For scripts: pipe output to head/tail can cause EPIPE (normal)
  2. 2For programs: ignore SIGPIPE signal with signal(SIGPIPE, SIG_IGN)
  3. 3Check write() return value for errors
  4. 4Use MSG_NOSIGNAL flag with send() on sockets

Tags

linuxerrnoerrno 32 epipetroubleshootingfix

More in Errno

Frequently Asked Questions

In piping commands, it is normal (e.g., yes | head). In network code, it means the client disconnected.