(Summary) Openwin Cmdtool can't find terminal

Guy Harris auspex!guy at uunet.uu.net
Wed Apr 24 10:00:00 AEST 1991


>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.




More information about the Comp.sys.sun mailing list