Path: utzoo!attcan!uunet!snorkelwacker!bloom-beacon!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.questions Subject: Re: tty Keywords: tty /dev Message-ID: <1990Feb6.142226.18001@athena.mit.edu> Date: 6 Feb 90 14:22:26 GMT References: <1044@prlhp1.prl.philips.co.uk> Sender: news@athena.mit.edu (News system) Reply-To: jik@athena.mit.edu (Jonathan I. Kamens) Organization: Massachusetts Institute of Technology Lines: 33 In article <1044@prlhp1.prl.philips.co.uk>, pearmana@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@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8495 Home: 617-782-0710