Can you poll a pipe?

Dave Lee dave at dptechno.UUCP
Wed Oct 31 07:48:35 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
[ stuff deleted about poll on pipes ].

I had a similar problem, I wanted a xterm type window as a sub window 
of a larger X application, where the user could run a program in the window, 
but still do other X stuff like menus.  

The best solution I found was to implement this with pty's, and select.
select() on ISC2.0.2 uses poll, but I wanted a "more portable" solution, 
and made the assumption that any X interface would also support select()
on the file descriptor associated with the display.  This has so far been
correct for all systems our X apps run on -- Sun,HP-UX,ISC2.0.2,SparcStation.

Then (of course) I got a little fancier, and wrote an X_Next() that would
allow you to queue up a list of file descriptors that desired input/output 
and arrange a callback routine to be called when input/output was availible.
Good place to place timer events also, since you are doing a select(), might
as well put the time to the next timer as the timeout time...

Note, that using pty's are more complicated than pipes, and more system 
dependant.  Not only do the ioctl's vary, but the filenames of the master
and slave devices vary, but oh well ...



-- 
Dave Lee
uunet!dptechno!dave



More information about the Comp.unix.sysv386 mailing list