Ethereal-dev: [Ethereal-dev] Named pipe

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Thomas Steffen <steffen.list.account@xxxxxxxxx>
Date: Tue, 27 Dec 2005 14:19:49 +0100
Dear Ethereal developers

Is there any way to determine (without side effects) that a pipe has
been closed? Writing to the pipe will give you EPIPE (and SIGPIPE) if
it is closed, but I cannot find a way to test this without writing
anything.

The background is that I am working on a program that receives packet
from a network connection and forwards them to Etherial via a named
pipe. I know that Ethereal can read from a named pipe, and it works
fine. However, after the user restarts capturing in Ethereal, the
program needs to send a new libpcap header.

I only found two ways to detect a closed end of the named pipe:
writing to it, and using select on it for reading. Select returns the
file descriptor ready for reading if the receiving end point is
closed. But this approach is not reliable, because I have to poll all
the time. If the writing process is busy, and does not call select at
the right moment, it can miss the time when the pipe is closed.

Any idea how to "subscribe" to a "pipe closed" event?

Thomas