Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site ptsfa.UUCP Path: utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!petrus!bellcore!decvax!decwrl!amdcad!lll-crg!qantel!ptsfa!jmc From: jmc@ptsfa.UUCP (Jerry Carlin) Newsgroups: net.bugs.usg,net.micro.att Subject: ttyname(bug) Message-ID: <1098@ptsfa.UUCP> Date: Mon, 13-Jan-86 17:58:55 EST Article-I.D.: ptsfa.1098 Posted: Mon Jan 13 17:58:55 1986 Date-Received: Wed, 15-Jan-86 08:08:12 EST Organization: Pacific * Bell, San Francisco Lines: 27 Keywords: ttyname, ttyslot, getlogin, syscon Xref: watmath net.bugs.usg:413 net.micro.att:796 On the 3B2 (and maybe other computers), ttyname(3C) has a bug. When you 'shutdown' the system from other than the console, /dev/syscon is linked to the /dev/tty from which you are running shutdown. ttyname() will return /dev/syscon after the system is rebooted if 'syscon' is before the tty in /dev. This is a problem since ttyslot(3C) uses the name returned by ttyname() to find the utmp entry. There will be no utmp entry for /dev/syscon and ttyslot() will return -1 (not 0 as the manual incorrectly states). Since getlogin(3C) uses ttyslot() (which uses ttyname()), it will erroneously return NULL (process not attached to a terminal). This is a classic "for want of a nail the shoe was lost; for want of a shoe the horse was lost...". If you are just looking for the login name, cuserid(3C) works fine as it does not go thru this process. Alternatively, one could either diddle /etc/rc to relink /dev/syscon or you could 'rm' and 'mknod' as necessary to force syscon to come after all the regular tty's in /dev. Or, for those with source, change ttyname.c to check for multiple links and take some sane action (like checking if any of them are in utmp) if such a condition is found. -- voice= 415 823-2441 uucp={ihnp4,dual,qantel}!ptsfa!jmc