Index of Section 2 Manual Pages
| Interix / SUA | getlogin.2 | Interix / SUA |
getlogin(2) getlogin(2)
getlogin()
NAME
getlogin(), getlogin_r() - get login name
SYNOPSIS
#include
char * getlogin(void)
int getlogin_r(char *name, size_t namesize)
DESCRIPTION
The getlogin(2) routine returns the login name of the user associated with
the current process. The name is normally associated with a login shell at
the time a session is created, and is inherited by all processes descended
from the login shell.
The reentrant getlogin_r(2) routine puts the name associated by the login
activity with the controlling terminal of the current process in the
character array identified by name. The array is namesize characters long
and should have space for the name and the terminating null character. The
maximum size of the login name is {LOGIN_NAME_MAX}.
If getlogin_r(2) is successful, upon return the name argument points to
the name the user used at login, even if there are several login names
with the same user ID.
Note that for both functions, the login name is returned in the format
domain+logname
While all Interix calls recognize the + character as a separator in a
login name, Win32 programs may not. If you will be passing the returned
string to a Win32 program, you may need to change the + character to a
backslash (\ ).
RETURN VALUES
If a call to getlogin(2) succeeds, it returns a pointer to a null-
terminated string in a static buffer. If the name has not been set, it
returns NULL.
On success, getlogin_r(2) returns zero; otherwise, it returns an error
number to indicate the error.
ERRORS
The getlogin(2) and getlogin_r(2) functions may fail if:
[EMFILE]
{OPEN_MAX} file descriptors are currently open in the calling process.
[ENFILE]
The maximum allowable number of files is currently open in the system.
[ENXIO]
The calling process has no controlling terminal.
The getlogin_r() function may fail if:
[ERANGE]
The value of namesize is smaller than the length of the string to be
returned including the terminating null character.
SEE ALSO
getpwnam(2)
getpwuid(2)
USAGE NOTES
The getlogin_r function is thread safe. The getlogin function is not
thread safe.
None of these functions are async-signal safe.