1 .\" Copyright (c) 1980, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)getrlimit.2 8.1 (Berkeley) 6/4/93
33 .\" $FreeBSD: src/lib/libc/sys/getrlimit.2,v 1.10.2.5 2001/12/14 18:34:00 ru Exp $
34 .\" $DragonFly: src/lib/libc/sys/getrlimit.2,v 1.4 2004/06/06 13:33:28 hmp Exp $
42 .Nd control maximum system resource consumption
50 .Fn getrlimit "int resource" "struct rlimit *rlp"
52 .Fn setrlimit "int resource" "const struct rlimit *rlp"
54 Limits on the consumption of system resources by the current process
55 and each process it creates may be obtained with the
57 call, and set with the
63 parameter is one of the following:
64 .Bl -tag -width RLIMIT_FSIZEAA
66 The largest size (in bytes)
68 file that may be created.
70 The maximum amount of cpu time (in seconds) to be used by
73 The maximum size (in bytes) of the data segment for a process;
74 this defines how far a program may extend its break with the
78 The largest size (in bytes) file that may be created.
80 The maximum size (in bytes) which a process may lock into memory
85 The maximum number of open files for this process.
87 The maximum number of simultaneous processes for this user id.
89 The maximum size (in bytes) to which a process's resident set size may
91 This imposes a limit on the amount of physical memory to be given to
92 a process; if memory is tight, the system will prefer to take memory
93 from processes that are exceeding their declared resident set size.
95 The maximum size (in bytes) of the stack segment for a process;
96 this defines how far a program's stack segment may be extended.
97 Stack extension is performed automatically by the system.
99 The maximum size (in bytes) of socket buffer usage for this user.
100 This limits the amount of network memory, and hence the amount of
101 mbufs, that this user may hold at any time.
102 .It Li RLIMIT_POSIXLOCK
103 The maximum number of POSIX-type advisory-mode locks available to
107 A resource limit is specified as a soft limit and a hard limit. When a
108 soft limit is exceeded a process may receive a signal (for example, if
109 the cpu time or file size is exceeded), but it will be allowed to
110 continue execution until it reaches the hard limit (or modifies
111 its resource limit). The
113 structure is used to specify the hard and soft limits on a resource,
114 .Bd -literal -offset indent
116 rlim_t rlim_cur; /* current (soft) limit */
117 rlim_t rlim_max; /* maximum value for rlim_cur */
121 Only the super-user may raise the maximum limits. Other users
124 within the range from 0 to
126 or (irreversibly) lower
131 value for a limit is defined as
134 Because this information is stored in the per-process information,
135 this system call must be executed directly by the shell if it
136 is to affect all future processes created by the shell;
138 is thus a built-in command to
141 The system refuses to extend the data or stack space when the limits
142 would be exceeded in the normal way: a
144 call fails if the data space limit is reached.
145 When the stack limit is reached, the process receives
148 if this signal is not
149 caught by a handler using the signal stack, this signal
150 will kill the process.
152 A file I/O operation that would create a file larger that the process'
153 soft limit will cause the write to fail and a signal
156 generated; this normally terminates the process, but may be caught. When
157 the soft cpu time limit is exceeded, a signal
170 The address specified for
174 The limit specified to
177 raised the maximum limit value, and the caller is not the super-user.
190 function call appeared in