Problem with pseudo ttys on Sun.

Rich Burridge richb at yarra.OZ
Mon Jul 7 10:35:44 AEST 1986


In article <3 at yarra.OZ>, richb at yarra.OZ, I write:
> 
> Say I used 'cat' to redirect a small file to /dev/ttyq5, as this was happening
> nfds returned a 1 to indicate that there was a file descriptor with 
> outstanding data to be read, and the readmask had the appropriate bit set.
> 
> nread normally contains the number of bytes read (which will be MAXDATA, up
> until the "last" time which will return a smaller value; the remainder left
> to read).
> Now what I would expect is that when I come to do the select call again, it
> should return 0 and the readmask should also be zero. But no, it tells me
> that there is data to be read, and when I use the read call as above, it
> returns -1 in nread with errno set to 5 (EIO I/O error).
> 
> Where am I going wrong?
> 

Steve Schoch at the NASA Ames Research Center provides the solution:

What the problem is is that after the 'cat' is done writing the file to
/dev/ttyq5, it exits, which closes that tty.  When you close a tty file for
the last time it causes it to hang up.  If this was a real tty, it would
drop DTR, but on a pseudo tty, it show that it is hung up by having the read
fail on the master side.

Select is correct in returning, and what you should do at this point is to
close the master side, as it is no use keeping it open past this point.


Many thanks Steve, nice to see somebody else works on a Sunday :-)

Regards Rich.

Rich Burridge            ISD:  +61 3 267-6222
Sun Australia            STD:  (03) 267-6222
14 Queens Rd,            ARPA: richb%yarra.oz at seismo.arpa
Melbourne, VIC 3004.     UUCP: seismo!munnari!yarra.oz!richb
AUSTRALIA.               ACS:  richb at yarra.oz
D



More information about the Comp.unix.wizards mailing list