ttyname() - question

Conor P. Cahill cpcahil at virtech.UUCP
Sat Sep 2 11:07:53 AEST 1989


After some more thought as to why ttyname(open("/dev/tty",0)) == "/dev/tty" 
as opposed to /dev/tty?? or whatever the name of the controlling terminal is,
I *think* I figured out the problem.

When open is called with the name "/dev/tty", it translates the name into
the inode (using the appropriate kernel routine such as namei()), and then
determines that the file to be opened is a device special file.

At this point the open calls the device specific open, which in 
this case just calls another device specific open (for the controlling
terminal).  The open code is not aware that the device that was 
actually opened is different than the one it thought was being opened and
so sets up the file table entries to point to /dev/tty.

-- 
+-----------------------------------------------------------------------+
| Conor P. Cahill     uunet!virtech!cpcahil      	703-430-9247	!
| Virtual Technologies Inc.,    P. O. Box 876,   Sterling, VA 22170     |
+-----------------------------------------------------------------------+



More information about the Comp.lang.c mailing list