Closing pty slaves

Gregory N. Bond gnb at melba.bby.oz
Wed Feb 8 15:18:17 AEST 1989


I have a little kludge program that I use to connect the SunOs (3.5)
print spooler to a serial printer on a terminal server.  It basically
allocates a pty, opens an internet socket and goes into a select loop
copying bytes from one to the other.  The printcap entry for the printer
specifies the pty slave as the device.

It works OK until the daemon closes the tty slave it has opened (at the
end of the print job).  At that point, the select returns with the pty
master ready for reading, but reading from the descriptor results in
EIO.

What I have done is opened the slave part of the tty in the program so
there never is a last close on the slave, and it all works fine.

Why does select return read ready?  It seems to me that if select says
read is OK, then read should work.  And a closed pty slave should result
in 0 bytes being read (or select not returning ready at all, or an
exception condition), until the slave is re-opened.

And is there a better way of using lp with a terminal server?  Is there
some kernel method for attaching a TCP stream to a pty?

Greg.
-- 
Gregory Bond, Burdett Buckeridge & Young Ltd, Melbourne, Australia
Internet: gnb at melba.bby.oz.au    non-MX: gnb%melba.bby.oz at uunet.uu.net
Uucp: {uunet,mnetor,pyramid,ubc-vision,ukc,mcvax,...}!munnari!melba.bby.oz!gnb



More information about the Comp.unix.wizards mailing list