tty

Jonathan I. Kamens jik at athena.mit.edu
Wed Feb 7 01:22:26 AEST 1990


In article <1044 at prlhp1.prl.philips.co.uk>, pearmana at prlhp1.prl.philips.co.uk
(Andy Pearman) writes:
> Could someone please remind me how the relation between
> 
> /dev/tty  and /dev/tty01  etc works

  RTFM, that'll at least get you started.  At least in BSD, the
following paragraph appears in the man page tty(4):

     The file /dev/tty is, in each process, a synonym for a con-
     trol terminal associated with that process.  It is useful
     for programs that wish to be sure of writing messages on the
     terminal no matter how output has been redirected.  It can
     also be used for programs that demand a file name for out-
     put, when typed output is desired and it is tiresome to find
     out which terminal is currently in use.

The actual link between "/dev/tty" and whatever tty you happen to be
using is accomplished in the kernel -- when a process attempts to open
/dev/tty, the file descriptor returned by the kernel is a file
descriptor for the controlling terminal of the process.

  The name "/dev/tty" is not really what's significant; instead, the
major and minor device numbers of the file /dev/tty are what tell the
kernel that it should be treated as the tty file.  If you were to create
another device with the same
device numbers and a different name, the kernel would still give you an
fd for the controlling terminal if you were to open it.

Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710



More information about the Comp.unix.questions mailing list