Penguin
Note: You are viewing an old revision of this page. View the current version.

Signal: Pipe

This signal is raised when a program writes to a socket or fifo that has no readers. The default action of this signal is to cause the program to terminate.

You might see this message if you have a series of commands in a shell pipe line and one of the processes quits. Eg
$ cat somefile | head

After "head" has printed out the first 10 lines and quits, "cat" will get a pipe error. However, cat catches the signal and quits gracefully. If you pipe the output of some cvs(1) commands into less(1) and quit, then you might see the shell print out a message as cvs doesn't handle this signal gracefully.

Another example, using strace(1) to show system calls

$ strace ls /etc | echo execve("/bin/ls", ["ls", "/etc"?, [/* 52 vars */?) = 0 ... write(1, "a2ps\nadjtime\napache2\napm\nasound."..., 1593) = -1 EPIPE (Broken pipe) --- SIGPIPE (Broken pipe) @ 0 (0) ---

  • ++ killed by SIGPIPE +++

$

If you get this message when writing to a socket, it can be avoided by passing MSG_NOSIGNAL as a flag to send() or ignoring the signal by using signal(SIGPIPE,SIG_IGN);