ACCT(2) — SYSTEM CALLS
NAME
acct − turn accounting on or off
SYNOPSIS
acct(file)
char ∗file;
DESCRIPTION
acct is used to enable or disable the process accounting. If process accounting is enabled, an accounting record will be written on an accounting file for each process that terminates. Termination can be caused by one of two things: an exit call or a signal; see exit(2) and sigvec(2). The effective user ID of the calling process must be super-user to use this call.
name points to a path name naming the accounting file. The accounting file format is given in acct(5).
The accounting routine is enabled if name is non-zero and no errors occur during the system call. It is disabled if name is zero and no errors occur during the system call.
If accounting is already turned on, and a successful acct call is made with a non-zero name, all subsequent accounting records will be written to the new accounting file.
NOTES
Accounting is automatically disabled when the file system the accounting file resides on runs out of space; it is enabled when space once again becomes available.
RETURN VALUE
The value −1 is returned if an error occurs, and external variable errno is set to indicate the cause of the error. Otherwise the value 0 is returned.
ERRORS
acct will fail if one of the following is true:
EPERM The caller is not the super-user.
ENOTDIR A component of the path prefix of file is not a directory.
EINVAL file contains a character with the high-order bit set.
EINVAL Support for accounting was not configured into the system.
ENAMETOOLONG
The length of a component of file exceeds 255 characters, or the length of file exceeds 1023 characters.
ENOENT The named file does not exist.
EACCES Search permission is denied for a component of the path prefix of file.
EACCES The file referred to by file is not a regular file.
ELOOP Too many symbolic links were encountered in translating the path name.
EROFS The named file resides on a read-only file system.
EFAULT file points outside the process’s allocated address space.
EIO An I/O error occurred while reading from or writing to the file system.
SEE ALSO
BUGS
No accounting is produced for programs running when a crash occurs. In particular non-terminating programs are never accounted for.
Sun Release 3.2 — Last change: 5 June 1986