getlogin
Purpose
Gets the user's login name.
Library
Standard C Library (libc.a)
Syntax
char *getlogin ( )
Description
The getlogin subroutine returns a pointer to the login
name as found in /etc/utmp. Use the getlogin subroutine
in conjunction with the getpwnam subroutine to locate the
correct password file entry when the same user ID is
shared by several login names.
If the getlogin subroutine is called within a process
that is not attached to a terminal, it returns a NULL
pointer. The correct procedure for determining the login
name is to call cuserid, or to call getlogin and if it
fails, then to call getpwuid.
If the login name is not found, getlogin returns a NULL
pointer.
Warning: The getlogin subroutine returns a pointer to a
static area that is overwritten by successive calls.
File
/etc/utmp
Related Information
In this book: "cuserid," "getgrent, getgrgid, getgrnam,
setgrent, endgrent," "getpwent, getpwuid, getpwnam,
setpwent, endpwent," and "utmp, wtmp, .ilog."