| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 3: Basic Library Functions Oracle Solaris 11 Information Library |
enable_extended_FILE_stdio(3C)
posix_spawnattr_getschedparam(3C)
posix_spawnattr_getschedpolicy(3C)
posix_spawnattr_getsigdefault(3C)
posix_spawnattr_getsigignore_np(3C)
posix_spawnattr_getsigmask(3C)
posix_spawnattr_setschedparam(3C)
posix_spawnattr_setschedpolicy(3C)
posix_spawnattr_setsigdefault(3C)
posix_spawnattr_setsigignore_np(3C)
posix_spawnattr_setsigmask(3C)
posix_spawn_file_actions_addclose(3C)
posix_spawn_file_actions_addclosefrom_np(3C)
posix_spawn_file_actions_adddup2(3C)
posix_spawn_file_actions_addopen(3C)
posix_spawn_file_actions_destroy(3C)
posix_spawn_file_actions_init(3C)
pthread_attr_getdetachstate(3C)
pthread_attr_getinheritsched(3C)
pthread_attr_getschedparam(3C)
pthread_attr_getschedpolicy(3C)
pthread_attr_setdetachstate(3C)
pthread_attr_setinheritsched(3C)
pthread_attr_setschedparam(3C)
pthread_attr_setschedpolicy(3C)
pthread_barrierattr_destroy(3C)
pthread_barrierattr_getpshared(3C)
pthread_barrierattr_setpshared(3C)
pthread_condattr_getpshared(3C)
pthread_condattr_setpshared(3C)
pthread_cond_reltimedwait_np(3C)
pthread_key_create_once_np(3C)
pthread_mutexattr_getprioceiling(3C)
pthread_mutexattr_getprotocol(3C)
pthread_mutexattr_getpshared(3C)
pthread_mutexattr_getrobust(3C)
pthread_mutexattr_setprioceiling(3C)
pthread_mutexattr_setprotocol(3C)
pthread_mutexattr_setpshared(3C)
pthread_mutexattr_setrobust(3C)
pthread_mutex_getprioceiling(3C)
pthread_mutex_reltimedlock_np(3C)
pthread_mutex_setprioceiling(3C)
pthread_rwlockattr_destroy(3C)
pthread_rwlockattr_getpshared(3C)
pthread_rwlockattr_setpshared(3C)
pthread_rwlock_reltimedrdlock_np(3C)
pthread_rwlock_reltimedwrlock_np(3C)
pthread_rwlock_timedrdlock(3C)
pthread_rwlock_timedwrlock(3C)
rctlblk_get_enforced_value(3C)
- user accounting database functions
#include <utmp.h>struct utmp *getutent(void);
struct utmp *getutid(const struct utmp *id);
struct utmp *getutline(const struct utmp *line);
struct utmp *pututline(const struct utmp *utmp);
voidsetutent(void);
voidendutent(void);
intutmpname(const char *file);
These functions provide access to the user accounting database,utmp. Entries inthe database are described by the definitions and data structures in<utmp.h>.
Theutmp structure contains the following members:
char ut_user[8]; /* user login name */char ut_id[4]; /* /etc/inittab id */ /* (usually line #) */char ut_line[12]; /* device name (console, lnxx) */short ut_pid; /* process id */short ut_type; /* type of entry */struct exit_status ut_exit; /* exit status of a process */ /* marked as DEAD_PROCESS */time_t ut_time; /* time entry was made */
The structureexit_status includes the following members:
short e_termination; /* termination status */short e_exit; /* exit status */
Thegetutent() function reads in the next entry from autmp database. If the database is not already open, it opens it. If it reaches the end of the database, it fails.
Thegetutid() function searches forward from the current point in theutmpdatabase until it finds an entry with aut_type matchingid->ut_type ifthe type specified isRUN_LVL,BOOT_TIME,DOWN_TIME,OLD_TIME, orNEW_TIME. If thetype specified inid isINIT_PROCESS,LOGIN_PROCESS,USER_PROCESS, orDEAD_PROCESS, thengetutid() willreturn a pointer to the first entry whose type is one ofthese four and whoseut_id member matchesid->ut_id. If the end ofdatabase is reached without a match, it fails.
Thegetutline() function searches forward from the current point in theutmpdatabase until it finds an entry of the typeLOGIN_PROCESS orut_linestring matching theline->ut_line string. If the end of database is reachedwithout a match, it fails.
Thepututline() function writes the suppliedutmp structure into theutmp database. It usesgetutid() to search forward for the proper place ifit finds that it is not already at the proper place. It is expected that normally the user ofpututline() will have searched forthe proper entry using one of the these functions. If so,pututline() will not search. Ifpututline() does not find a matchingslot for the new entry, it will add a new entry to theend of the database. It returns a pointer to theutmpstructure. When called by a non-root user,pututline() invokes asetuid() rootprogram to verify and write the entry, since theutmp database isnormally writable only by root. In this event, theut_name member mustcorrespond to the actual user name associated with the process; theut_type member must be eitherUSER_PROCESS orDEAD_PROCESS; and theut_line member mustbe a device special file and be writable by the user.
Thesetutent() function resets the input stream to the beginning. Thisreset should be done before each search for a new entry ifit is desired that the entire database be examined.
Theendutent() function closes the currently open database.
Theutmpname() function allows the user to change the name of thedatabase file examined to another file. If the file does notexist, this will not be apparent until the first attempt to referencethe file is made. Theutmpname() function does not open the filebut closes the old file if it is currently open and savesthe new file name.
A null pointer is returned upon failure to read, whether for permissionsor having reached the end of file, or upon failure to write.If the file name given is longer than 79 characters,utmpname() returns0. Otherwise, it returns1.
These functions use buffered standard I/O for input, butpututline() uses anunbuffered non-standard write to avoid race conditions between processes trying to modifytheutmp andwtmp databases.
Applications should not access theutmp andwtmp databases directly, but shoulduse these functions to ensure that these databases are maintained consistently. Usingthese functions, however, may cause applications to fail if user accounting datacannot be represented properly in theutmp structure (for example, on a systemwhere PIDs can exceed 32767). Use the functions described on thegetutxent(3C) manual page instead.
Seeattributes(5) for descriptions of the following attributes:
|
getutxent(3C),ttyslot(3C),utmpx(4),attributes(5)
The most current entry is saved in a static structure. Multipleaccesses require that it be copied before further accesses are made. Oneach call to eithergetutid() orgetutline(), the function examines the staticstructure before performing more I/O. If the contents of the static structurematch what it is searching for, it looks no further. Forthis reason, to usegetutline() to search for multiple occurrences, it wouldbe necessary to zero out the static area after each success, orgetutline() would just return the same structure over and over again. There isone exception to the rule about emptying the structure before further readsare done. The implicit read done bypututline() (if it findsthat it is not already at the correct place in the file)will not hurt the contents of the static structure returned by thegetutent(),getutid() orgetutline() functions, if the user has just modified those contentsand passed the pointer back topututline().
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |