OSDN Git Service

Update README
[linuxjm/LDP_man-pages.git] / original / man3 / getlogin.3
index 3a259ee..01163b2 100644 (file)
@@ -1,7 +1,6 @@
-.\" Hey Emacs! This file is -*- nroff -*- source.
-.\"
 .\" Copyright 1995  James R. Van Zandt <jrv@vanzandt.mv.com>
 .\"
+.\" %%%LICENSE_START(VERBATIM)
 .\" Permission is granted to make and distribute verbatim copies of this
 .\" manual provided the copyright notice and this permission notice are
 .\" preserved on all copies.
 .\"
 .\" Formatted or processed versions of this manual, if unaccompanied by
 .\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
 .\"
 .\" Changed Tue Sep 19 01:49:29 1995, aeb: moved from man2 to man3
 .\"  added ref to /etc/utmp, added BUGS section, etc.
 .\" modified 2003 Walter Harms, aeb - added getlogin_r, note on stdin use
-.TH GETLOGIN 3 2008-06-29 "GNU" "Linux Programmer's Manual"
+.TH GETLOGIN 3 2013-04-19 "GNU" "Linux Programmer's Manual"
 .SH NAME
 getlogin, getlogin_r, cuserid \- get username
 .SH SYNOPSIS
@@ -53,7 +53,7 @@ _XOPEN_SOURCE
 .BR getlogin ()
 returns a pointer to a string containing the name of
 the user logged in on the controlling terminal of the process, or a
-NULL pointer if this information cannot be determined.
+null pointer if this information cannot be determined.
 The string is
 statically allocated and might be overwritten on subsequent calls to
 this function or to
@@ -69,7 +69,7 @@ of size
 returns a pointer to a string containing a username
 associated with the effective user ID of the process.
 If \fIstring\fP
-is not a NULL pointer, it should be an array that can hold at least
+is not a null pointer, it should be an array that can hold at least
 \fBL_cuserid\fP characters; the string is returned in this array.
 Otherwise, a pointer to a string in a static area is returned.
 This
@@ -92,10 +92,12 @@ For most purposes, it is more useful to use the environment variable
 \fBLOGNAME\fP to find out who the user is.
 This is more flexible
 precisely because the user can set \fBLOGNAME\fP arbitrarily.
-.SH "RETURN VALUE"
+.SH RETURN VALUE
 .BR getlogin ()
 returns a pointer to the username when successful,
-and NULL on failure.
+and NULL on failure, with
+.I errno
+set to indicate the cause of the error.
 .BR getlogin_r ()
 returns 0 when successful, and nonzero on failure.
 .SH ERRORS
@@ -108,11 +110,11 @@ The calling process already has the maximum allowed number of open files.
 The system already has the maximum allowed number of open files.
 .TP
 .B ENXIO
-The calling process has no controlling tty.
+The calling process has no controlling terminal.
 .TP
 .B ERANGE
 (getlogin_r)
-The length of the username, including the terminating null byte,
+The length of the username, including the terminating null byte (\(aq\\0\(aq),
 is larger than
 .IR bufsize .
 .LP
@@ -135,7 +137,21 @@ password database file
 \fI/var/run/utmp\fP
 (traditionally \fI/etc/utmp\fP;
 some libc versions used \fI/var/adm/utmp\fP)
-.SH "CONFORMING TO"
+.SH ATTRIBUTES
+.SS Multithreading (see pthreads(7))
+The
+.BR getlogin ()
+function is not thread-safe.
+.LP
+The
+.BR getlogin_r ()
+function is thread-safe.
+.LP
+The
+.BR cuserid ()
+function is thread-safe with exceptions.
+It is not thread-safe if called with a NULL parameter.
+.SH CONFORMING TO
 .BR getlogin ()
 and
 .BR getlogin_r ()
@@ -157,7 +173,7 @@ OpenBSD has
 and
 .BR setlogin (),
 and a username
-associated with a session, even if it has no controlling tty.
+associated with a session, even if it has no controlling terminal.
 .SH BUGS
 Unfortunately, it is often rather easy to fool
 .BR getlogin ().
@@ -165,7 +181,7 @@ Sometimes it does not work at all, because some program messed up
 the utmp file.
 Often, it gives only the first 8 characters of
 the login name.
-The user currently logged in on the controlling tty
+The user currently logged in on the controlling terminal
 of our program need not be the user who started it.
 Avoid
 .BR getlogin ()
@@ -190,7 +206,16 @@ instead, if that is
 what you meant.
 .B Do not use
 .BR cuserid ().
-.SH "SEE ALSO"
+.SH SEE ALSO
 .BR geteuid (2),
 .BR getuid (2),
 .BR utmp (5)
+.SH COLOPHON
+This page is part of release 3.79 of the Linux
+.I man-pages
+project.
+A description of the project,
+information about reporting bugs,
+and the latest version of this page,
+can be found at
+\%http://www.kernel.org/doc/man\-pages/.