Email List: Xaustin-group-lX
[All Lists]

Re: [1003.1(2008)/Issue 7 0000172]: getlogin() and fds 0, 1 and 2

To: austin-group-l@xxxxxxxxxxxxx
Subject: Re: [1003.1(2008)/Issue 7 0000172]: getlogin() and fds 0, 1 and 2
From: Vincent Lefevre <vincent-opgr@xxxxxxxxxx>
Date: Fri, 23 Oct 2009 15:06:11 +0200
Mail-followup-to: austin-group-l@opengroup.org
References: <7e35158108b4a82fcb3cda84d71ce540>
On 2009-10-23 09:35:38 +0000, Austin Group Bug Tracker wrote:
> Most (possibly all) implementations of getlogin() rely internally on
> file descriptor 0, 1 or 2 being open to the terminal in order to find
> it.  If all three fds are redirected, for example to plain files or
> /dev/null, getlogin() fails (with ENOTTY).  The standard does not
> mention this.

FYI, not all implementations: logname works under Mac OS X 10.4.11
even when all the file descriptors 0, 1 and 2 are redirected, e.g.

  logname < /dev/null > out 2> /dev/null

The file "out" contains the login name.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)

<Prev in Thread] Current Thread [Next in Thread>