getutxline() — Search by line utmpx database

Standards

Standards / Extensions C or C++ Dependencies

XPG4.2
Single UNIX Specification, Version 3

both  

Format

#define _XOPEN_SOURCE_EXTENDED 1
#include <utmpx.h>

struct utmpx *getutxline(const struct utmpx *line);

General description

The getutxline() function searches forward from the current point in the utmpx database until it finds an entry of the type LOGIN_PROCESS or USER_PROCESS which also has a ut_line value matching that in the utmpx structure pointed to by argument line. If the database is not already open, it opens it. If it reaches the end of the database, it fails.

The pututxline() function obtains an exclusive lock in the utmpx database on the byte range of the record which is ready to write and releases the lock before returning to its caller. The functions getutxent(), getutxid(), and getutxline() might continue to read and are not affected by pututxline().

Because the getutxline() function returns thread-specific data the getutxline() function can be used safely from a multithreaded application. If multiple threads in the same process open the database, then each thread opens the database with a different file descriptor. The thread's database file descriptor is closed when the calling thread terminates or the endutxent() function is called by the calling thread.

The name of the database file defaults to /etc/utmpx. To process a different database file name use the __utmpxname() function.

The functions getutxent(), getutxid(), and getutxline() cache the last entry read from the database. For this reason, to use getutxline() function to search for multiple occurrences, it is necessary to zero out the utmpx structure pointed to by the return value from these functions.

For all entries that match a request, the ut_type member indicates the type of the entry. Other members of the entry will contain meaningful data based on the value of the ut_type member as follows:
EMPTY
No other members have meaningful data.
BOOT_TIME
ut_tv is meaningful.
__RUN_LVL
ut_tv and ut_line are meaningful
OLD_TIME
ut_tv is meaningful.
NEW_TIME
ut_tv is meaningful.
USER_PROCESS
ut_id, ut_user (login name of the user), ut_line, ut_pid, and ut_tv are meaningful.
INIT_PROCESS
ut_id, ut_pid, and ut_tv are meaningful.
LOGIN_PROCESS
ut_id, ut_user (implementation-specific name of the login process), ut_pid, and ut_tv are meaningful.
DEAD_PROCESS
ut_id, ut_pid, and ut_tv are meaningful.

Returned value

If successful, getutxline() returns a pointer to a utmpx structure containing a copy of the requested entry in the user accounting database.

If unsuccessful, getutxline() returns a NULL pointer.

No errors are defined for this function.

Related information