Broken Pipe is a standard error that occures on Unix like OSes. Whenever a pipe that you are writing to dies, SIGPIPE is raised.

Socket connections are pipes. Here's a little scenario:
  1. Open a connection to remote server
  2. Remote server dies, but you don't know or ignore that
  3. You try to write something to the socket
  4. The OS raises a SIGPIPE error indicating that nothing should be written to the pipe anymore

(A UN*X signal:)
SIGPIPE is the "broken pipe" signal on UNIX, Linux, and the other Unixoids. It is sent to a process which tries to write to a pipe (or socket, or any similar stream) which the other side has already closed for reading. There is nothing which could be done with such data -- it must vanish.

TCP connections are modeled after UNIXy pipes, so it should come as no surprise that writing to a half-closed TCP connection will result in the OS delivering SIGPIPE.

Here's one way to generate SIGPIPE in the comfort of your own $HOME. We shall use a named pipe (or fifo)...

$ mkfifo foo
If we write to foo, the process will block, waiting for a reader (the data are still not lost!).
$ cat bar >foo &
Now redirect a process which consumes no input to "read" from foo:
$ echo < foo
Voila! SIGPIPE!

Log in or registerto write something here or to contact authors.