Skip to content.

plope

Personal tools
You are here: Home » Members » chrism's Home » Supervisor 1.0.5 Released » Hmm pipes are always ready?
 
 

Comment

Above in this comment thread: Supervisor 1.0.5 Released » Hmm... poll? » oops... » poll intervals

Hmm pipes are always ready?

Posted by mattk at 2004-08-03 07:39 PM
I don't really recall pipes being always ready to read. It's been a while since I looked at how programs like tail work (ie does tail do millisecond sleeps to check EOF, or what?).

When you open the files do you open them in blocking or non blocking modes? I presume you're opening them O_NONBLOCK and waiting for result E_WOULDBLOCK in your main read loop for those file descriptors.

select on pipes

> I don't really recall pipes being always ready to read. It's been a while since I looked at
> how programs like tail work (ie does tail do millisecond sleeps to check EOF, or what?)

GNU tail does sleep in a loop on "tail -f" and doesn't use select at all.

Related info from the "select" manpage:

Three independent sets of descriptors are watched. Those listed in
readfds will be watched to see if characters become available for read-
ing (more precisely, to see if a read will not block - in particular, a
file descriptor is also ready on end-of-file) ....

The "file descriptor is also ready on end-of-file" is the problem. Since "ready" is defined to include streams at EOF, and because quiet streams are almost always at EOF, select is not useful for waiting on pipe activity. It's pretty lame.

> When you open the files do you open them in blocking or non blocking modes? I presume you're
> opening them O_NONBLOCK and waiting for result E_WOULDBLOCK in your main read loop for those
> file descriptors.

That's right.