Previous: XPG Functions, Up: User Accounting Database
These functions, derived from BSD, are available in the separate
libutil library, and declared in utmp.h.
Note that the ut_user member of struct utmp is called
ut_name in BSD. Therefore, ut_name is defined as an alias
for ut_user in utmp.h.
This function makes filedes the controlling terminal of the current process, redirects standard input, standard output and standard error output to this terminal, and closes filedes.
This function returns
0on successful completion, and-1on error.
The
loginfunctions inserts an entry into the user accounting database. Theut_linemember is set to the name of the terminal on standard input. If standard input is not a terminalloginuses standard output or standard error output to determine the name of the terminal. Ifstruct utmphas aut_typemember,loginsets it toUSER_PROCESS, and if there is anut_pidmember, it will be set to the process ID of the current process. The remaining entries are copied from entry.A copy of the entry is written to the user accounting log file.
This function modifies the user accounting database to indicate that the user on ut_line has logged out.
The
logoutfunction returns1if the entry was successfully written to the database, or0on error.
The
logwtmpfunction appends an entry to the user accounting log file, for the current time and the information provided in the ut_line, ut_name and ut_host arguments.
Portability Note: The BSD struct utmp only has the
ut_line, ut_name, ut_host and ut_time
members. Older systems do not even have the ut_host member.