__utmpxname() — Change the utmpx database name

Standards

Standards / Extensions C or C++ Dependencies
z/OS® UNIX both  

Format

#define _XOPEN_SOURCE_EXTENDED 1
#include <utmpx.h>

int __utmpxname(char *file);

General description

The __utmpxname() function changes the name of the utmpx database file for the current thread from default /etc/utmpx to the name specified by file. The __utmpxname() function does not open the file. It closes the old utmpx database file, if it is currently opened for the current thread, and saves the new utmpx database file name. If the file does not exist no indication is given.

Because the __utmpxname() function processes thread-specific data the __utmpxname() 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.

Programs must not reference the data passed back by getutxline(), getutxid(), getutxent(), or pututxline() after __utmpxname() has been called (the storage has been freed.) The endutxent() function resets the name of the utmpx database back to the default value. If you must do additional utmpx operations on a nonstandard utmpx database after calling endutxent(), then call __utmpxname() again, to reestablish the nonstandard name.

Returned value

If successful, __utmpxname() returns 0.

If unsuccessful, __utmpxname() returns -1.