Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!oliveb!ames!sgi!arisia!janssen@holmes From: janssen@holmes (Bill Janssen) Newsgroups: comp.windows.x Subject: Re: Xlib not seeing net connection drop? Message-ID: <1379@arisia.Xerox.COM> Date: 25 Jun 89 22:33:02 GMT References: <8906251323.AA27600@Larry.McRCIM.McGill.EDU> Sender: news@arisia.Xerox.COM Reply-To: janssen@holmes (Bill Janssen) Organization: PARC.Xerox.COM Lines: 39 In-reply-to: mouse@LARRY.MCRCIM.MCGILL.EDU (der Mouse) You might try looking for bytes on the wire, thusly: while (1) { if (XQLength(disp) > 0) { read events and act on them } choose a timeout for the select - see below call select() on the pty and XConnectionNumber(disp) if (the select timed out) { if (the window needs updating) update it if (there might be stuff to flush to the X server) { XSync(disp,False); /* see below */ } continue; } if (select indicates something on the X connection) { + unsigned long count; + + if (ioctl(ConnectionNumber(disp), FIONREAD, &count) == 0 + && count < 1) + EOFonXconnectionRoutine(); + else XEventsQueued(disp,QueuedAfterReading); continue; } if (select indicates something on the pty) { handle stuff on the pty } } Should work on SunOS 3.5. Properly speaking, the routine to be called should handle exceptions on that fd, not just EOF. Include sys/filio.h to get the definition of FIONREAD. Bill Bill Janssen janssen@xerox.com (415) 494-4763 Xerox Palo Alto Research Center 333 Coyote Hill Road, Palo Alto, California 94304