getutxid() — Search by ID utmpx database
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 |
both |
Format
#define _XOPEN_SOURCE_EXTENDED 1
#include <utmpx.h>
struct utmpx *getutxid(const struct utmpx *id);
General description
The getutxid() function searches forward from the current point in the utmpx database. If the database is not already open, it opens it. If the ut_type value of the utmpx structure pointed to by id is BOOT_TIME, __RUN_LVL, OLD_TIME, or NEW_TIME, then it stops when it finds an entry with a matching ut_type value. If the ut_type value is INIT_PROCESS, LOGIN_PROCESS, USER_PROCESS, or DEAD_PROCESS, then it stops when it finds an entry whose type is one of these four and whose ut_id member matches the ut_id member of the utmpx structure pointed to by id. If the UT_type value is EMPTY, getutxid() fails (returns NULL) without repositioning the utmpx database to the end. If the end of the of the database is reached without a match, getutxid() 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 getutxid() function returns thread-specific data the getutxid() 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.
- 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, getutxid() returns a pointer to a utmpx structure containing a copy of the requested entry in the user accounting database.
If unsuccessful, getutxid() returns a NULL pointer.
No errors are defined for this function.