Xref: utzoo comp.unix.internals:912 comp.unix.sysv386:1722 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!dptechno!dave From: dave@dptechno.UUCP (Dave Lee) Newsgroups: comp.unix.internals,comp.unix.sysv386 Subject: Re: Can you poll a pipe? Message-ID: <601@dptechno.UUCP> Date: 30 Oct 90 20:48:35 GMT References: <1990Oct24.184556.853@esegue.segue.boston.ma.us> Reply-To: dave@dptechno.UUCP (Dave Lee) Followup-To: comp.unix.internals Distribution: na Organization: D.P. Technology Corp. Camarillo California Lines: 31 In article <1990Oct24.184556.853@esegue.segue.boston.ma.us> johnl@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