xref: /freebsd/lib/libsys/getrlimitusage.2 (revision 3670421e21932c44225b9457c50dd67da3abcd84)
1.\" Copyright (c) 2024 The FreeBSD Foundation, Inc.
2.\"
3.\" This documentation was written by
4.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
5.\" from the FreeBSD Foundation.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS 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 AUTHORS 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 September 27, 2024
29.Dt GETRLIMITUSAGE 2
30.Os
31.Sh NAME
32.Nm getrlimitusage
33.Nd Query usage of the current process' limited resources
34.Sh LIBRARY
35.Lb libc
36.Sh SYNOPSIS
37.In sys/resource.h
38.Ft int
39.Fn getrlimitusage "unsigned which" "int flags" "rlim_t *res"
40.Sh DESCRIPTION
41The
42.Nm
43system call allows the process to query current consumption of the resources
44limited by the
45.Xr setrlimit 2
46call.
47.Pp
48The
49.Fa which
50argument specifies the resource, same as for
51.Xr getrlimit 2
52and
53.Xr setrlimit 2
54calls, see their man page for the list of enforced resource types.
55.Pp
56The
57.Fa flags
58argument modifies the behavior of the call in the following ways:
59.Bl -tag -width GETRLIMITUSAGE_XXXXXX
60.It Va GETRLIMITUSAGE_EUID
61Query the resource usage for user identified by effective UID of the process,
62instead of the real UID (which is default for accounting).
63.El
64.Sh RETURN VALUES
65.Rv -std
66.Sh ERRORS
67The
68.Fn getrlimitusage
69system call will fail if:
70.Bl -tag -width Er
71.It Bq Er EFAULT
72The address specified for
73.Fa res
74is invalid.
75.It Bq Er EINVAL
76The resource specified to
77.Fn getrlimitusage
78in the
79.Fa which
80argument is unknown.
81.It Bq Er ENXIO
82The resource specified to
83.Fn getrlimitusage
84in the
85.Fa which
86argument is not accounted, but only enforced in specific situations.
87Examples of such resources are
88.Va RLIMIT_FSIZE
89and
90.Va RLIMIT_CORE .
91.El
92.Sh SEE ALSO
93.Xr procstat 1 ,
94.Xr getrlimit 2 ,
95.Xr setrlimit 2 .
96.Sh HISTORY
97The
98.Fn getrlimitusage
99system call appeared in
100.Bx 15.0 .
101