Can you poll a pipe?

William G. Bunton wgb at balkan.TNT.COM
Wed Oct 31 01:01:51 AEST 1990


In article <1990Oct28.035350.26736 at ico.isc.com> dougm at ico.ISC.COM (Doug McCallum) writes:
>In article <345 at uucs1.UUCP> gaf at uucs1.UUCP () writes:
>...
>>That's funny - I've been told by ISC in no uncertain terms that poll()
>>doesn't work on a FIFO, since it isn't a streams device.  This info came
>>back from a bug report I gave them complaining that select() appeared not
>>to be working properly on FIFOs.  select() calls poll(), and as you say
>>poll() only works on streams devices.

I've been told the same, in the same terms, about tty devices.  In
fact, I reported that select (which, as we all know, calls poll), when
run on a tty, will hang the entire console/vt subsystem until the
program issueing the select (poll) terminates.  The response was:

"select is a Berkeley-ism, unsupported in this usage by Unix V3."

I swear I read that ISC modified poll to work on pipes and ttys.  But
even if not, it would seem more reasonable for poll to return an
error, or ignore that descriptor, rather than freezing the console.

>about this, poll is supposed to work on pipes and tty devices under 2.2
>and definitely did in the 1.0.6 release. Poll works on tty devices but
>did not work on pipes (or FIFOs) under 2.0.1 or 2.0.2.

Yes, poll works on tty devices (as long as the driver is asy, not fas.
If fas, the console/vt system seems to survive, it's the program
issueing the poll that has problems), but at the expense of the
console.  This doesn't seem like an acceptable trade-off to me.

>I just checked and you are correct in the behavior.  Apparently when the poll
>support was added back in it was not done completely.

I'd like to suggest that when poll support was added back in for tty
devices it was not done completely either.  Note that it works fine
when run on one of the ports on my ACE card, but not when run on a COM
(i.e. tty0[01]).

If anyone is interested, here's a nice short program that when run on
a tty will freeze the console until the program is killed:

--------- cut here ---------------
#include <stdio.h>
#include <stropts.h>
#include <poll.h>

main()
{
    struct pollfd pfd;

    pfd.fd = 0;
    pfd.events = POLLIN;

    poll(&pfd, 1, -1);
}
------------ cut here -----------


Bill
-- 
William G. Bunton              | An engineer is a man who can do for five bob
wgb at balkan.tnt.com             | what any bloody fool can do for a quid.
Tools & Techniques, Austin, TX |                        -- origin unknown



More information about the Comp.unix.internals mailing list