.TH getlogin() "" "" "General Function (libc)"
.PC "Get login name"
.B "#include <unistd.h>"
\fBchar *getlogin(\|)\fR
.PP
The name corresponding to the current user id
is not always the same as the name under which
a user logged into the \*(CO system.
For example, the user may have issued a
.B su
command, or there may be several login names associated with a user id.
.B getlogin()
returns the login name found in the file
.B /etc/utmp.
.PP
In cases where
.B getlogin()
fails to produce a result,
.B getpwuid()
(described in
.BR getpwent() )
is normally used to
determine the user name for a process.
.SH Files
\fB/etc/utmp\fR \*(EM login names
.SH "See Also"
.Xr "getpwent()," getpwent
.Xr "getuid()," getuid
.Xr "libc," libc
.Xr "su," su
.Xr "ttyname()," ttyname
.Xr "unistd.h," unistd.h
.Xr "utmp.h," utmp.h
.Xr "who" who
.br
\*(PX Standard, \(sc4.2.4
.SH Diagnostics
.B getlogin()
returns NULL if the login name cannot be determined.
.SH Notes
.B getlogin()
stores the returned name in a static area
that is destroyed by subsequent calls.
