ACCT(2) — SYSTEM CALLS
NAME
acct − turn accounting on or off
SYNOPSIS
int acct (path)
char ∗path;
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.
path points to a path name naming the accounting file. The accounting file format is given in acct(5).
The accounting routine is enabled if path is not a NULL pointer and no errors occur during the system call. It is disabled if path is a NULL pointer and no errors occur during the system call.
If accounting is already turned on, and a successful acct() call is made with a non-NULL path, all subsequent accounting records will be written to the new accounting file.
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 path is not a directory.
EINVAL Support for accounting was not configured into the system.
ENAMETOOLONG The length of a component of path exceeds 255 characters, or the length of path exceeds 1023 characters.
ENOENT The named file does not exist.
EACCES Search permission is denied for a component of the path prefix of path.
EACCES The file referred to by path 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 path 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
exit(2), sigvec(2), acct(5), sa(8)
BUGS
No accounting is produced for programs running when a crash occurs. In particular non-terminating programs are never accounted for.
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.
Sun Release 4.0 — Last change: 20 November 1987