Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!snorkelwacker!bloom-beacon!eru!luth!sunic!dkuug!compel!her From: her@compel.UUCP (Helge Egelund Rasmussen) Newsgroups: comp.unix.wizards Subject: Getting tty name without using ttyname(3) Keywords: ttyname Message-ID: <673@compel.UUCP> Date: 15 Feb 90 09:37:32 GMT Organization: Compel, Copenhagen, DK Lines: 25 I need to write a replacement for the SYSV release 3 ttyname(3) function. The reason is that the ttyname call is veeeery slow on our machine (5 to 10 seconds). As far as I can see by prof'ing a test program, ttyname calls stat(2) on the files in /dev until it finds the correct tty (its doing about 300 stat calls!). Presumably ttyname is comparing the 'st_rdev' field in the stat structure with something identifying the current tty. I'd like to know what the ttyname call really is doing. I need the call to identify the terminal used by the current process (for logging purposes), so it's not enough to get "/dev/tty" as answer.. Any help would be appreciated. Helge --- Helge E. Rasmussen . PHONE + 45 31 37 11 00 . E-mail: her@compel.dk Compel A/S . FAX + 45 31 37 06 44 . Copenhagen, Denmark