getutx(3C)getutx(3C)NAME
getutx: endutxent(), getutxent(), getutxid(), getutxline(), pututx‐
line(), setutxent() - access utmpx file entry
SYNOPSIS
Remarks:
The field in the structure is deprecated and will be obsoleted and
removed in a future release. If this field is needed, use the func‐
tions (see getuts(3C)).
DESCRIPTION
and each return a pointer to a structure of the following type:
struct utmpx {
char ut_user[24]; /* User login name */
char ut_id[4]; /* /etc/inittab id (usually line #) */
char ut_line[12]; /* device name (console, lnxx) */
pid_t ut_pid; /* process id */
short ut_type; /* type of entry */
struct __exit_status {
short __e_termination; /* Process termination status */
short __e_exit; /* Process exit status */
} ut_exit; /* The exit status of a process */
/* marked as DEAD_PROCESS. */
unsigned short ut_reserved1; /* Reserved for future use */
struct timeval {
time_t tv_sec; /* seconds */
long tv_usec; /* and microseconds */
} ut_tv; /* time entry was made */
char ut_host[64]; /* host name, if remote; NOT SUPPORTED */
unsigned long ut_addr; /* Internet addr of host, if remote; */
/* TO BE OBSOLETED */
char ut_reserved2[12] ; /* Reserved for future use */
};
Reads in the next entry from a
file. If the file is not already open, opens it.
If it reaches the end of the file, fails.
Searches forward from the current point in the
utmpx file until it finds an entry with a matching
id−>ut_type if the type specified is or If the type
specified in id is or returns a pointer to the
first entry whose type is one of these four, and
whose field matches id−>ut_id. If end-of-file is
reached without a match, fails.
Searches forward from the current point in the
utmpx file until it finds an entry of type or that
also has a string matching the line−>ut_line
string. If end-of-file is reached without a match,
fails.
Writes out the supplied
structure into the utmpx file, translates the sup‐
plied structure into a structure and writes it to a
utmp file. uses to search forward for the proper
location if it is not already there. It is nor‐
mally expected that the application program has
already searched for the proper entry by using one
of the routines before calling If the search has
already been made, does not repeat it. If does not
find a matching slot for the new entry, it adds a
new entry to the end of the file.
Resets the input stream to the beginning of the file.
This should be done before each search for a new
entry if it is desired that the entire file be
examined.
Closes the currently open file.
The most current entry is saved in a static structure. Multiple
accesses require that the structure be copied before further accesses
are made. During each call to either or the static structure is exam‐
ined before performing more I/O. If the contents of the static struc‐
ture match what the routine is searching for, no additional searching
is done. Therefore, if using to search for multiple occurrences, it is
necessary to zero out the static structure after each success; other‐
wise simply returns the same pointer over and over again. There is one
exception to the rule about removing the structure before a new read:
The implicit read done by (if it finds that it is not already at the
correct place in the file) does not alter the contents of the static
structure returned by or if the user has just modified those contents
and passed the pointer back to
RETURN VALUE
These functions return a NULL pointer upon failure to read (whether for
permissions or having reached end-of-file), or upon failure to write.
They also return a NULL pointer if the size of the file is not an inte‐
gral multiple of
If is successful, it returns a pointer to a static location containing
the most current entry. The contents of this structure are identical
to the contents of the supplied structure if successful. If fails upon
writing to it returns a NULL pointer. If is successful in writing to
the file but fails in writing to the file, then will behave as if it
succeeded. Note that the file and the file may not be in sync due to
the above behavior. is only guaranteed to have written to the file
upon successful completion.
WARNINGS
The field in the structure is deprecated and will be obsoleted and
removed in a future release. If this field is needed, use the func‐
tions (see getuts(3C)).
FILESSEE ALSOgetuts(3C), getutent(3C), getuts(3C), ttyslot(3C), utmp(4),
thread_safety(5).
STANDARDS CONFORMANCEgetutx(3C)