NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | ERRORS | ATTRIBUTES | SEE ALSO
#include <sys/exacct.h>size_t getacct(idtype_t idtype, id_t id, void *buf, size_t bufsize);
These functions provide access to the extended accounting facility.
The getacct() function returns extended accounting buffers from the kernel for currently executing tasks and processes. The resulting data buffer can be examined using the functions of the extended accounting library, libexacct(3LIB).
The putacct() function provides privileged processes the ability to tag accounting records with additional data specific to that process. For instance, a queuing facility may wish to record which queue a given task or process was submitted to prior to running. The flags field determines whether the contents of buf should be treated as raw data or as an embedded exacct structure, as described in <sys/exacct.h>. The use of an inappropriate flag or the inclusion of corrupt exacct data will likely corrupt the enclosing exacct file.
The wracct() function requests the kernel to write, given its internal state of resource usage, the appropriate data for the specified task or process. The flags field determines whether a partial (EW_PARTIAL) or interval record (EW_INTERVAL) is written.
These functions require root privilege, as they allow inquiry or reporting relevant to system tasks and processes other than the invoking process. The putacct() and wracct() functions also cause the kernel to write records to the system's extended accounting files.
The getacct() function returns the number of bytes required to represent the extended accounting record for the requested system task or process. If bufsize exceeds the returned size, buf will contain a valid accounting record buffer. If bufsize is less than the return value, buf will contain the first bufsize bytes of the record. In the event of failure, -1 is returned and errno is set to indicate the error.
The putacct() and wracct() functions return 0 if the record was successfully written. Otherwise, -1 is returned and errno is set to indicate the error.
The getacct(), putacct(), and wracct() functions will fail if:
The idtype argument was not P_TASKID or P_PID.
The file system containing the extended accounting file is full. The wracct() or putacct() function will fail if the record size would exceed the amount of space remaining on the file system.
The extended accounting facility for the requested idtype_t is not active. Either putacct() attempted to write a task record when the task accounting file was unset, or getacct() attempted to retrieve accounting data for a process when extended process accounting was inactive.
The invoking process lacks sufficient permission to perform the request operation.
The id argument does not refer to a presently active system task ID or process ID.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE |
ATTRIBUTE VALUE |
---|---|
MT-Level |
Async-Signal-Safe |
NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | ERRORS | ATTRIBUTES | SEE ALSO