Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!inuxc!iuvax!bsu-cs!dhesi From: dhesi@bsu-cs.UUCP Newsgroups: comp.unix.questions Subject: Re: Identify file name given file descriptor Message-ID: <692@bsu-cs.UUCP> Date: Fri, 22-May-87 13:22:43 EDT Article-I.D.: bsu-cs.692 Posted: Fri May 22 13:22:43 1987 Date-Received: Sat, 23-May-87 10:39:43 EDT References: <710@twitch.UUCP> <877@killer.UUCP> <1037@hropus.UUCP> Reply-To: dhesi@bsu-cs.UUCP (Rahul Dhesi) Organization: CS Dept, Ball St U, Muncie, Indiana Lines: 25 Keywords: microport, ttyname, cu Following up on the discussion of how to find a name given a file descriptor, I want to point out that the ttyname() library function already does that to a limited extent. It accepts a file descriptor and returns the name of the terminal device corresponding to it. Presumably it only searches /dev. And the name it finds that may not be the one that is needed. Using cu under Microport System V/AT when multiple links exist to the same serial device, I find that cu creates the lock file /usr/spool/uucp/LCK..tty0 when it is invoked, because /dev/tty0 is the default device for cu. But when it exits, it does not use the same name, because it apparently calls ttyname() and uses whatever name is returned. In my case it tries to then remove the lock file /usr/spool/uucp/LCK..ttycg and fails to find it and complains. This was clearly an oversight on part of the author, who assumed that there would be only one link to a serial device. The right thing to do would be to always use ttyname(), so no matter how many links exist, the same lock file will be used for the same physical device. I found similar strange things happening under 4.3BSD if there was more than one link to a terminal in /dev, though I don't remember which program (tip or cu or uucico) was affected. -- Rahul Dhesi UUCP: {ihnp4,seismo}!{iuvax,pur-ee}!bsu-cs!dhesi