xref: /openbsd-src/share/man/man9/lim_cur.9 (revision 56e834a205e77779e889b22f62abe807e2a9bb1f)
1.\"	$OpenBSD: lim_cur.9,v 1.2 2019/06/21 12:56:46 visa Exp $
2.\"
3.\" Copyright (c) 2019 Visa Hankala
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: June 21 2019 $
18.Dt LIM_CUR 9
19.Os
20.Sh NAME
21.Nm lim_cur ,
22.Nm lim_cur_proc ,
23.Nm lim_fork ,
24.Nm lim_free ,
25.Nm lim_read_enter ,
26.Nm lim_read_leave
27.Nd Resource limit interface
28.Sh SYNOPSIS
29.In sys/types.h
30.In sys/resourcevar.h
31.Ft rlim_t
32.Fn "lim_cur" "int which"
33.Ft rlim_t
34.Fn "lim_cur_proc" "struct proc *p" "int which"
35.Ft struct plimit *
36.Fn "lim_fork" "struct process *parent" "struct process *child"
37.Ft void
38.Fn "lim_free" "struct plimit *limit"
39.Ft struct plimit *
40.Fn "lim_read_enter"
41.Ft void
42.Fn "lim_read_leave" "struct plimit *limit"
43.Sh DESCRIPTION
44The resource limit interface provides read access to the resource limits
45of the process.
46.Pp
47.Fn lim_cur
48returns the value of limit
49.Fa which
50of the current process.
51The
52.Fa which
53can take one of the following values:
54.Bd -literal
55#define RLIMIT_CPU	0	/* cpu time in milliseconds */
56#define RLIMIT_FSIZE	1	/* maximum file size */
57#define RLIMIT_DATA	2	/* data size */
58#define RLIMIT_STACK	3	/* stack size */
59#define RLIMIT_CORE	4	/* core file size */
60#define RLIMIT_RSS	5	/* resident set size */
61#define RLIMIT_MEMLOCK	6	/* locked-in-memory address space */
62#define RLIMIT_NPROC	7	/* number of processes */
63#define RLIMIT_NOFILE	8	/* number of open files */
64.Ed
65.Pp
66.Fn lim_cur_proc
67is like
68.Fn lim_cur
69but returns the value of limit
70.Fa which
71of thread
72.Fa p .
73.Pp
74.Fn lim_read_enter
75begins read access to the current process' resource limit structure.
76.Pp
77.Fn lim_read_leave
78finishes read access to the resource limit structure.
79.Pp
80Sections denoted by
81.Fn lim_read_enter
82and
83.Fn lim_read_leave
84cannot nest.
85Using
86.Fn lim_cur
87inside the read section is not allowed
88because the function uses
89.Fn lim_read_enter
90and
91.Fn lim_read_leave
92internally.
93.Pp
94.Fn lim_free
95releases the reference
96.Fa limit .
97.Pp
98.Fn lim_fork
99makes the process
100.Fa child
101share the resource limits of process
102.Fa parent .
103.Sh CONTEXT
104.Fn lim_cur ,
105.Fn lim_cur_proc ,
106.Fn lim_fork ,
107.Fn lim_free ,
108.Fn lim_read_enter
109and
110.Fn lim_read_leave
111can be called during autoconf, or from process context.
112.Sh RETURN VALUES
113.Fn lim_cur
114and
115.Fn lim_cur_proc
116return the value of the given resource limit.
117.Pp
118.Fn lim_read_enter
119returns a read reference to the current process' resource limits.
120