Can you poll a pipe?

Doug McCallum dougm at ico.isc.com
Fri Oct 26 07:10:45 AEST 1990


In article <1990Oct24.184556.853 at esegue.segue.boston.ma.us> johnl at iecc.cambridge.ma.us (John R. Levine) writes:
>I am writing some X code in which I want to display items to the screen as
>they arrive from a back end via a pipe.  To do a reasonable job, I need to
>read both X events and pipe data at the same time.  Under Sys V, there is
>a handy poll() call similar to the BSD select() call that lets you wait until
>there is activity on any of a set of file descriptors.

Definitely something that was needed in SYSV.

>
>The problem is that, according to the manual, poll() is only guaranteed to
>work on Streams devices.  A little experimentation shows that under ISC 2.2
>polling a pipe works nicely, but it's not clear whether that is standard
>behavior or an ISC improvement.  (There is such a thing as a streams pipe,
>but the standard pipe system call doesn't make one, it makes a nameless FIFO,
>as usual.)

I don't know anyone else that added it, I haven't looked, but it is definitely
an ISC addition.  It was asked for a LOT as was using poll on tty devices.  It
is nice but applications using it won't be portable.  Under V.3, pipes are
still done the old way and not with STREAMS.  Under V.4, this all changes.

In most cases, the STREAMS pipe mechanism can substitute for real pipes.
Of course, it isn't guaranteed that STREAMS pipes will ship with all systems.

>
>Does anyone with experience with other Sys V versions know whether polling
>pipes is always supposed to work?  Since I only need to do this under X, we
>can assume that streams are in the kernel, since without them X won't work.

There are two mechanisms for doing STREAMS pipe types of things.  The
original STREAMS pipe was /dev/spx and was used by RFS.  This is what
ISC uses in X.  Then there is the STREAMS pty mechanism (/dev/ptmx, /dev/pts???)
which can also be used for STREAMS terminal type things. /dev/spx has
less overhead and existed prior to V.3.1 where /dev/ptmx did not exist
in the earlier releases.  The pty stuff is a little clunkier to deal with
but is more likely to be shipped.  It is also what AT&T uses for local X
clients.

Doug McCallum
Interactive Systems Corp
dougm at ico.isc.com



More information about the Comp.unix.sysv386 mailing list