xref: /freebsd/lib/libsys/acct.2 (revision f126890a)
1.\" Copyright (c) 1980, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd March 30, 2020
29.Dt ACCT 2
30.Os
31.Sh NAME
32.Nm acct
33.Nd enable or disable process accounting
34.Sh LIBRARY
35.Lb libc
36.Sh SYNOPSIS
37.In unistd.h
38.Ft int
39.Fn acct "const char *file"
40.Sh DESCRIPTION
41The
42.Fn acct
43system call enables or disables the collection of system accounting
44records.
45If the argument
46.Fa file
47is a null pointer, accounting is disabled.
48If
49.Fa file
50is an
51.Em existing
52pathname (null-terminated), record collection is enabled and for
53every process initiated which terminates under normal
54conditions an accounting record is appended to
55.Fa file .
56Abnormal conditions of termination are reboots
57or other fatal system problems.
58Records for processes which never terminate cannot be
59produced by
60.Fn acct .
61.Pp
62For more information on the record structure used by
63.Fn acct ,
64see
65.In sys/acct.h
66and
67.Xr acct 5 .
68.Pp
69This call is permitted only to the super-user.
70.Sh NOTES
71Accounting is automatically disabled when the file system the
72accounting file resides on runs out of space; it is enabled when
73space once again becomes available.
74The values controlling this behaviour can be modified using the following
75.Xr sysctl 8
76variables:
77.Bl -tag -width ".Va kern.acct_chkfreq"
78.It Va kern.acct_chkfreq
79Specifies the frequency (in seconds) with which free disk
80space should be checked.
81.It Va kern.acct_resume
82The percentage of free disk space above which process
83accounting will resume.
84.It Va kern.acct_suspend
85The percentage of free disk space below which process
86accounting will suspend.
87.El
88.Sh RETURN VALUES
89On error -1 is returned.
90The file must exist and the call may be exercised only by the super-user.
91.Sh ERRORS
92The
93.Fn acct
94system call will fail if one of the following is true:
95.Bl -tag -width Er
96.It Bq Er EPERM
97The caller is not the super-user.
98.It Bq Er ENOTDIR
99A component of the path prefix is not a directory.
100.It Bq Er ENAMETOOLONG
101A component of a pathname exceeded 255 characters,
102or an entire path name exceeded 1023 characters.
103.It Bq Er ENOENT
104The named file does not exist.
105.It Bq Er EACCES
106Search permission is denied for a component of the path prefix,
107or the path name is not a regular file.
108.It Bq Er ELOOP
109Too many symbolic links were encountered in translating the pathname.
110.It Bq Er EROFS
111The named file resides on a read-only file system.
112.It Bq Er EFAULT
113The
114.Fa file
115argument
116points outside the process's allocated address space.
117.It Bq Er EIO
118An I/O error occurred while reading from or writing to the file system.
119.It Bq Er EINTEGRITY
120Corrupted data was detected while reading from the file system.
121.El
122.Sh SEE ALSO
123.Xr acct 5 ,
124.Xr accton 8 ,
125.Xr sa 8
126.Sh HISTORY
127The
128.Fn acct
129function appeared in
130.At v7 .
131