EPIPE is a return value (errno) when writing to a file under Unix system. Its an attempt to write to a broken pipe.
When a process ignores the SIGPIPE
, the writing system call returns with an EPIPE
error. So processes wanting to handle the broken pipe manually would typically ignore SIGPIPE
and take action upon a EPIPE
error.
SIGPIPE
is for situations like this:
grep "pattern" < reallyhugefile | head
grep might print millions of lines, but head only reads 10 then quits. Once head closes the read-end and quits, grep gets SIGPIPE
, which kills it, forcing it to quit early instead of processing the entire file uselessly.
If you don't want your program to be killed, handle or block SIGPIPE
yourself. You will start getting write-errors with errno
set to EPIPE
instead.
https://unix.stackexchange.com/questions/84813/what-makes-a-unix-process-die-with-broken-pipe