Xref: utzoo comp.lang.c:21414 comp.lang.c++:4536 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!uunet!virtech!cpcahil From: cpcahil@virtech.UUCP (Conor P. Cahill) Newsgroups: comp.lang.c,comp.lang.c++ Subject: Re: ttyname() - question Message-ID: <1111@virtech.UUCP> Date: 2 Sep 89 01:07:53 GMT References: <99@lkbpyr.UUCP> <1088@virtech.UUCP> <14481@haddock.ima.isc.com> <1107@virtech.UUCP> Organization: Virtual Technologies Inc Lines: 19 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 | +-----------------------------------------------------------------------+