| 1 | .\" @(#)getlogin.3 6.3 (Berkeley) %G% |
| 2 | .\" |
| 3 | .TH GETLOGIN 3 "" |
| 4 | .AT 3 |
| 5 | .SH NAME |
| 6 | getlogin \- get login name |
| 7 | .SH SYNOPSIS |
| 8 | .B char *getlogin() |
| 9 | .SH DESCRIPTION |
| 10 | .I Getlogin |
| 11 | returns a pointer to the login name as found in |
| 12 | .IR /var/run/utmp . |
| 13 | It may be used in conjunction with |
| 14 | .I getpwnam |
| 15 | to locate the correct password file entry when the same userid |
| 16 | is shared by several login names. |
| 17 | .PP |
| 18 | If |
| 19 | .I getlogin |
| 20 | is called within a process that is not attached to a |
| 21 | terminal, or if there is no entry in |
| 22 | .I /var/run/utmp |
| 23 | for the process's terminal, |
| 24 | .I getlogin |
| 25 | returns a NULL pointer (0). |
| 26 | A reasonable procedure for determining the login name is to first call |
| 27 | .I getlogin |
| 28 | and if it fails, to call |
| 29 | .IR getpwuid ( getuid ()). |
| 30 | .SH FILES |
| 31 | /var/run/utmp |
| 32 | .SH "SEE ALSO" |
| 33 | getpwent(3), utmp(5), ttyslot(3) |
| 34 | .SH DIAGNOSTICS |
| 35 | Returns a NULL pointer (0) if name not found. |
| 36 | .SH BUGS |
| 37 | The return values point to static data |
| 38 | whose content is overwritten by each call. |