Getting tty name without using ttyname(3)
brnstnd at stealth.acf.nyu.edu
brnstnd at stealth.acf.nyu.edu
Fri Feb 16 11:09:25 AEST 1990
In article <673 at compel.UUCP> her at compel.UUCP (Helge Egelund Rasmussen) writes:
> I need to write a replacement for the SYSV release 3 ttyname(3) function.
ttyname() takes a file descriptor argument and (as you observed) searches
through /dev for a tty (or just any file? I haven't checked) referencing
the same inode. If you have a lot of non-tty entries in /dev, you could
write a much faster version that only looks at files beginning with tty.
Of course, to avoid confusion you shouldn't call this ttyname().
Use directory(3), stat(2). (The whole thing is a kludge.)
---Dan
More information about the Comp.unix.wizards
mailing list