Path: utzoo!utgpu!cunews!bnrgate!brchh104!brchs1!bnr.ca!rice.edu!sun-spots-request From: auspex!guy@uunet.uu.net (Guy Harris) Newsgroups: comp.sys.sun Subject: Re: (Summary) Openwin Cmdtool can't find terminal Keywords: Windows Message-ID: <2615@brchh104.bnr.ca> Date: 24 Apr 91 00:00:00 GMT Sender: news@brchh104.bnr.ca Organization: Sun-Spots Lines: 33 Approved: Sun-Spots@rice.edu X-Original-Date: 20 Apr 91 23:46:41 GMT X-Refs: Original: v10n70 X-Sun-Spots-Digest: Volume 10, Issue 88, message 4 X-Note: Submissions: sun-spots@rice.edu, Admin: sun-spots-request@rice.edu >The 'moral' is exactly how does cmdtool determine that a terminal is >available? Obviously, not by the ownership of the terminal. Does it look >in /etc/utmp? No. As with other programs on systems with BSD-flavored pseudo-ttys (which includes some systems that claim to be in the S5 camp), they do it by trying to open the "master" side device for all pseudo-ttys, and stopping as soon as they find one that they can open. The "slave" is the device that looks like a tty, e.g. "/dev/ttyp0". The "master" is the device to which "shelltool" or "cmdtool" or "xterm" or "script" or "{in.}rlogind" or "{in.}telnetd" or whatever writes stuff in order to make that stuff show up as input on the "slave", and from which those programs read stuff that is written as output to the "slave". The master for "/dev/ttyp0" is "/dev/ptyp0". "Master" devices are exclusive-use devices; if process A has one open, nobody else can open it. Unfortunately, you can end up with a pseudo-tty that has no process on the master side, *but* that still has some process using the slave side. That will look as if it's available for use by programs that use pseudo-ttys, but once that program fires up something to use the slave side (a shell, or whatever), the shell it fires up may end up fighting with the process that already has the slave side open, with unpleasant results for both parties.... It is also conceivable that there's a problem somewhere in the pseudo-tty driver such that the pseudo-tty slave side doesn't get properly "cleaned out" when the last process that has the slave side open exits.