On 23 Apr 1998 04:56:12 -0700, Guy Maor <[EMAIL PROTECTED]> said: > Roderick Schertler <[EMAIL PROTECTED]> writes: >> >> getlogin() is supposed to work even if isatty(0) is false. It is bug >> #17528. > > How can it? If isatty() is false, then ttyname(3) is null, so > getlogin() can't look up the entry in utmp.
It's supposed to open /dev/tty instead of using stdin. This is the way it works on all the systems I could get people to check for me, which are Linux with libc5, AIX 4.2, Solaris 2.4, Solaris 2.5, DG/UX 4.11 and FreeBSD 2.2.2-R. Here's an example (from dgux): # who | grep 'pts/[45] ' roderick pts/4 Apr 23 02:01 ccost pts/5 Apr 23 09:11 # tty /dev/pts/4 # cat getlogin #!/usr/bin/perl -lw $l = getlogin; print defined($l) ? $l : 'undef'; # ./getlogin roderick # ./getlogin < /dev/pts/5 roderick # ./getlogin < /dev/null roderick # setsid ./getlogin undef # -- Roderick Schertler [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]