Path: utzoo!attcan!uunet!stealth.acf.nyu.edu!brnstnd From: brnstnd@stealth.acf.nyu.edu Newsgroups: comp.unix.wizards Subject: Re: Getting tty name without using ttyname(3) Message-ID: <15137:00:09:24@stealth.acf.nyu.edu> Date: 16 Feb 90 00:09:25 GMT References: <673@compel.UUCP> Reply-To: brnstnd@stealth.acf.nyu.edu (Dan Bernstein) Organization: IR Lines: 12 In article <673@compel.UUCP> her@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