From: Bob Cruder (bcruder@csn.org)
Date: 08/27/93


From: bcruder@csn.org (Bob Cruder)
Subject: Re: /dev/tty (Whatis it for?)
Date: Sat, 28 Aug 1993 00:34:10 GMT

Oliver Paulzen (paulzen@salyko.cube.net) wrote:
: C.W. Southern (cws9669@ultb.isc.rit.edu) schrieb:
: > I am having a program with serial logins on my machine. I am running SLS
: > 1.03. I have a good connection between the two, and when I try to connect
: > the to together it will get as far as the Password: prompt then stop. So I
: > ran strace on getty and found for some reason that the login program switches
: > ttys from /dev/ttys2 (COM3) to /dev/tty. When this file is removed the login
: > process continues as normal. But this file (/dev/tty) is required when loading
: > xterm up under X-windows. I have a few questions. What is the reason for this
: > file (/dev/tty)? The only way that I can find around it is to patch login
: > program, is there another?

I haven't examined the Linux internals in sufficient detail but found
/dev/tty used in SVR3. There, /dev/tty is simply an alias for the com
device into which one has logged.

Even if one has redirected stdin and stdout, a program can access /dev/tty
and be able to send output to or get input from the user screen. If a program
needs to use io control instructions to turn off echo for password entry
or to set raw mode for an editor, it need only point to /dev/tty.

Problem is, some programs are able to open either the original tty or
/dev/tty in an exclusive mode which makes programs fail when they attempt
a reopen via the other name. On SVR3 it only affects my console, occurs
only after a reboot and goes away after the system has been running for a
while.

Perhaps a kernel hacker in the audience can tell us where the semaphore is
that locks each tty device.

Bob Cruder - bcruder@miaco.com