2.9BSD/usr/man/man3/getlogin.3

Compare this file to the similar file:
Show the results in this format:

.TH GETLOGIN 3 
.UC
.SH NAME
getlogin \- get login name
.SH SYNOPSIS
.B char *getlogin();
.SH DESCRIPTION
.I Getlogin
returns a pointer to
the login name
as found in
.IR /etc/utmp .
It may be used
in conjunction
with
.I getpwnam
to locate the correct
password file entry
when the same userid
is shared by several
login names.
.PP
If
.I getlogin
is called within a process
that is not attached to a
typewriter, it returns NULL.
.SH FILES
/etc/utmp
.SH "SEE ALSO"
getpwent(3), getgrent(3), utmp(5)
.SH DIAGNOSTICS
Returns NULL if name not found.
.SH BUGS
The return values point to static data
whose contents are overwritten by each call.
.I Getlogin
is almost useless.  It attempts to determine the user name by first determining
whether file descriptors 0, 1, or 2 are attached to ttys.  If so, /etc/utmp is
used to associate a user name.  The deficiencies of this method are clear.
.I Getlogin
should
.B never
be used when security is a consideration.