xref: /netbsd/lib/libc/sys/acct.2 (revision bf9ec67e)
1.\"	$NetBSD: acct.2,v 1.12 2002/02/08 01:28:16 ross Exp $
2.\"
3.\" Copyright (c) 1980, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\"    must display the following acknowledgement:
16.\"	This product includes software developed by the University of
17.\"	California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\"     @(#)acct.2	8.1 (Berkeley) 6/4/93
35.\"
36.Dd June 4, 1993
37.Dt ACCT 2
38.Os
39.Sh NAME
40.Nm acct
41.Nd enable or disable process accounting
42.Sh LIBRARY
43.Lb libc
44.Sh SYNOPSIS
45.Fd #include \*[Lt]unistd.h\*[Gt]
46.Ft int
47.Fn acct "const char *file"
48.Sh DESCRIPTION
49The
50.Fn acct
51call enables or disables the collection of system accounting
52records.
53If the argument
54.Fa file
55is a nil pointer, accounting is disabled.
56If
57.Fa file
58is an
59.Em existing
60pathname (null-terminated), record collection is enabled and for
61every process initiated which terminates under normal
62conditions an accounting record is appended to
63.Fa file .
64Abnormal conditions of termination are reboots
65or other fatal system problems.
66Records for processes which never terminate can not be
67produced by
68.Fn acct .
69.Pp
70For more information on the record structure used by
71.Fn acct ,
72see
73.Pa /usr/include/sys/acct.h
74and
75.Xr acct 5 .
76.Pp
77This call is permitted only to the super-user.
78.Sh NOTES
79Accounting is automatically disabled when the file system the
80accounting file resides on runs out of space; it is enabled when
81space once again becomes available.
82For this purpose,
83.Fn acct
84creates a kernel thread called
85.Dq acctwatch .
86.Sh RETURN VALUES
87On error -1 is returned.
88The file must exist and the call may be exercised only by the super-user.
89.Sh ERRORS
90.Fn acct
91will fail if one of the following is true:
92.Bl -tag -width Er
93.It Bq Er EPERM
94The caller is not the super-user.
95.It Bq Er ENOTDIR
96A component of the path prefix is not a directory.
97.It Bq Er ENAMETOOLONG
98A component of a pathname exceeded
99.Dv {NAME_MAX}
100characters, or an entire path name exceeded
101.Dv {PATH_MAX}
102characters.
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
113.Fa file
114points outside the process's allocated address space.
115.It Bq Er EIO
116An I/O error occurred while reading from or writing to the file system.
117.El
118Also,
119.Fn acct
120fails if failed to create kernel thread described above.
121See
122.Xr fork 2
123for
124.Va errno
125value.
126.Sh SEE ALSO
127.Xr fork 2 ,
128.Xr acct 5 ,
129.Xr sa 8
130.Sh HISTORY
131An
132.Fn acct
133function call appeared in
134.At v7 .
135