Thread-Safe C Library (libc_r.a)
int getlogin_r (Name, Length) char *Name; size_t Length;
The getlogin_r subroutine gets a user's login name from the /etc/utmp file and places it in the Name parameter. Only the number of bytes specified by the Length parameter (including the ending null value) are placed in the Name parameter.
Applications that call the getlogin_r subroutine must allocate memory for the login name before calling the subroutine. The name buffer must be the length of the Name parameter plus an ending null value.
If the getlogin_r subroutine cannot find the login name in the utmp file or the process is not attached to a terminal, it places the LOGNAME environment variable in the name buffer. If the LOGNAME environment variable does not exist, the Name parameter is set to null and the getlogin_r subroutine returns a -1.
0 | Indicates that the subroutine was successful. |
-1 | Indicates that the subroutine was not successful. |
If the getlogin_r subroutine does not succeed, it returns one of the following error codes:
This subroutine is part of Base Operating System (BOS) Runtime. Programs using this subroutine must link to the libpthreads.a library.
/etc/utmp | Contains a record of users logged into the system. |
The getgrent_r, getgrgid_r, getgrnam_r, setgrent_r, or endgrent_r subroutine, getlogin subroutine, getpwent_r, getpwnam_r, putpwent_r, getpwuid_r, setpwent_r, or endpwent_r subroutine.
List of Security and Auditing Subroutines, List of Multithread Subroutines, and Subroutines Overview in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.