getlogin(S) 6 January 1993 getlogin(S) Name getlogin - get login name Syntax cc . . . -lc char *getlogin () Description The getlogin routine returns a pointer to the login name as found in the file /etc/utmp. If getlogin is called within a process that is not attached to a terminal, it returns a NULL pointer. getlogin may be used in conjunction with the getpwnam routine to locate the correct password file entry when the same user ID is shared by several login names. The correct procedure for determining the login name is to call the cuserid or the getlogin routine. If both fail, one should call the getpwuid routine. Return value Upon successful completion, the getlogin routine returns a pointer to the login name. If the login name is not found or if an error while access- ing the /etc/utmp file occurs, getlogin returns the NULL pointer. Note The return value points to static data whose content is overwritten by each call. Therefore, the information should be copied if it needs to be saved or used later. Files /etc/utmp See also cuserid(S), getgrent(S), getpwent(S), utmp(F) Standards conformance getlogin conforms with: AT&T SVID Issue 2; X/Open Portability Guide, Issue 3, 1989; IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C Language] (ISO/IEC 9945-1); and NIST FIPS 151-1.