ENDUTXENT(3P)
πΈ endutxent, getutxent, getutxid, getutxline, pututxline, setutxent β bestie's guide to the user accounting database π
okay so first things first: this page is part of the POSIX Programmer's Manual (that's the manual name, we're in the 3P section, POSIX gang π). Heads up tho β the Linux implementation of this interface may differ, so pls go consult the corresponding Linux manual page for the deets on Linux behavior. Or, plot twist, the interface might not even be implemented on Linux at all. π vibe check your platform first, fr fr.
β¨ PROLOG β¨
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ β consult the corresponding Linux manual page for details of Linux behavior β or the interface may not be implemented on Linux. π
π¦ NAME π¦
endutxent, getutxent, getutxid, getutxline, pututxline, setutxent β user accounting database functions. that's the whole squad, no cap.
π SYNOPSIS π
#include <utmpx.h>
void endutxent(void);
struct utmpx *getutxent(void);
struct utmpx *getutxid(const struct utmpx *id);
struct utmpx *getutxline(const struct utmpx *line);
struct utmpx *pututxline(const struct utmpx *utmpx);
void setutxent(void);
look at that gorgeous little lineup π
π DESCRIPTION π
These functions shall provide access to the user accounting database. that's the whole mission statement, bestie.
The getutxent() function shall read the next entry from the user accounting database. If the database is not already open, it shall open it. And if it reaches the end of the database, it shall fail. π (rip, end of the road.)
The getutxid() function shall search forward from the current point in the database. Here's the tea on when it stops:
- If the
ut_typevalue of theutmpxstructure pointed to by id isBOOT_TIME,OLD_TIME, orNEW_TIME, then it shall stop when it finds an entry with a matchingut_typevalue. - If the
ut_typevalue isINIT_PROCESS,LOGIN_PROCESS,USER_PROCESS, orDEAD_PROCESS, then it shall stop when it finds an entry whose type is one of these four and whoseut_idmember matches theut_idmember of theutmpxstructure pointed to by id.
If the end of the database is reached without a match, getutxid() shall fail. π
The getutxline() function shall search forward from the current point in the 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 line. If the end of the database is reached without a match, getutxline() shall fail.
β οΈ ok sogetutxid()orgetutxline()may cache data. For this reason, to usegetutxline()to search for multiple occurrences, the application shall zero out the static data after each success, orgetutxline()may return a pointer to the sameutmpxstructure. not me forgetting to zero the struct and getting the exact same pointer back... embarrassing. π
There is one exception to the rule about clearing the structure before further reads are done. The implicit read done by pututxline() (if it finds that it is not already at the correct place in the user accounting database) shall not modify the static structure returned by getutxent(), getutxid(), or getutxline(), if the application has modified this structure and passed the pointer back to pututxline(). special little guy exemption, iconic. π
For all entries that match a request, the ut_type member indicates the type of the entry. Other members of the entry shall contain meaningful data based on the value of the ut_type member, like so:
EMPTYβ No othersBOOT_TIMEβut_tvOLD_TIMEβut_tvNEW_TIMEβut_tvUSER_PROCESSβut_id,ut_user(login name of the user),ut_line,ut_pid,ut_tvINIT_PROCESSβut_id,ut_pid,ut_tvLOGIN_PROCESSβut_id,ut_user(implementation-defined name of the login process),ut_line,ut_pid,ut_tvDEAD_PROCESSβut_id,ut_pid,ut_tv
An implementation that provides extended security controls may impose implementation-defined restrictions on accessing the user accounting database. In particular, the system may deny the existence of some or all of the user accounting database entries associated with users other than the caller. privacy era, we respect it. π«Ά
If the process has appropriate privileges, the pututxline() function shall write out the structure into the user accounting database. It shall search for a record as if by getutxid() that satisfies the request. If this search succeeds, then the entry shall be replaced. Otherwise, a new entry shall be made at the end of the user accounting database.
The endutxent() function shall close the user accounting database.
The setutxent() function shall reset the input to the beginning of the database. This should be done before each search for a new entry if it is desired that the entire database be examined. rewind era, slay. βͺ
These functions need not be thread-safe. ngl, noted. π
π₯ RETURN VALUE π₯
Upon successful completion, getutxent(), getutxid(), and getutxline() shall return a pointer to a utmpx structure containing a copy of the requested entry in the user accounting database. Otherwise, a null pointer shall be returned.
The return value may point to a static area which is overwritten by a subsequent call to getutxid() or getutxline(). it's giving "same pointer, different day" π
Upon successful completion, pututxline() shall return a pointer to a utmpx structure containing a copy of the entry added to the user accounting database. Otherwise, a null pointer shall be returned.
The endutxent() and setutxent() functions shall not return a value. void kings. π
π ERRORS π
No errors are defined for the endutxent(), getutxent(), getutxid(), getutxline(), and setutxent() functions. clean records, we love that for them β¨
The pututxline() function may fail if:
EPERMβ The process does not have appropriate privileges.
The following sections are informative. (yes bestie, that means the next few sections are the bonus content, not the rules π)
π EXAMPLES π
None. that's it. no examples. we're all just out here rawdogging the POSIX spec. π
πΈ APPLICATION USAGE πΈ
The sizes of the arrays in the structure can be found using the sizeof operator. handy lil tip, use it. π
π§ RATIONALE π§
None.
β FUTURE DIRECTIONS β
None.
π SEE ALSO π
The Base Definitions volume of POSIX.1β2017, <utmpx.h>
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie!! π«Ά this lil masterpiece was brought to you by IEEE/The Open Group, dated 2017, filed under ENDUTXENT(3P). go forth and read your utmpx structs responsibly. mwah π
β¨
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms