1 .\" Copyright (c) 1996 David Nugent <davidn@blaze.net.au>
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, is permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice immediately at the beginning of the file, without modification,
9 .\" this list of conditions, and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
13 .\" 3. This work was done expressly for inclusion into FreeBSD. Other use
14 .\" is permitted provided this notation is included.
15 .\" 4. Absolutely no warranty of function or purpose is made by the author
17 .\" 5. Modifications may be freely made to this file providing the above
18 .\" conditions are met.
27 .Nd set or display process resource limits
30 .Op Fl C Ar class | Fl P Ar pid | Fl U Ar user
33 .Op Fl bcdflmnstuvpw Op Ar val
35 .Op Fl C Ar class | Fl U Ar user
37 .Op Fl bcdflmnstuvpw Op Ar val
40 .Op Ar name Ns = Ns Ar value ...
46 utility either prints or sets kernel resource limits, and may optionally set
47 environment variables like
49 and run a program with the selected resources.
53 .Bl -tag -width indent
57 .Op Ar name Ns = Ns Ar value ...
60 This usage sets limits according to
62 optionally sets environment variables given as
63 .Ar name Ns = Ns Ar value
64 pairs, and then runs the specified
66 .It Nm Op Ar limitflags
67 This usage determines values of resource settings according to
69 does not attempt to set them and outputs these values to
71 By default, this will output the current kernel resource settings
72 active for the calling process.
77 options, you may also display the current resource settings modified
78 by the appropriate login class resource limit entries from
81 login capabilities database.
82 .It Nm Fl e Op Ar limitflags
83 This usage determines values of resource settings according to
85 but does not set them itself.
86 Like the previous usage, it outputs these values to standard
87 output, except that it will emit them in
89 format, suitable for the calling shell.
90 The calling shell is determined by examining the entries in the
92 file system for the parent process.
93 If the shell is known (i.e., it is one of
94 .Nm sh , csh , bash , tcsh , ksh , pdksh
102 commands in the format understood by
104 If the name of the shell cannot be determined, then the
110 This is very useful for setting limits used by scripts, or prior
111 launching of daemons and other background tasks with specific
112 resource limit settings, and provides the benefit of allowing
113 global configuration of maximum resource usage by maintaining a
114 central database of settings in the login class database.
116 Within a shell script,
118 will normally be used with eval within backticks as follows:
120 .Dl "eval `limits -e -C daemon`"
122 which causes the output of
124 to be evaluated and set by the current shell.
129 specified in the above contains one or more of the following options:
130 .Bl -tag -width ".Fl C Ar class"
132 Use current resource values, modified by the resource entries applicable
136 Use current resource values, modified by the resource entries applicable
137 to the login class the
140 If user does not belong to any class, then the resource capabilities
143 class are used, if it exists, or the
145 class if the user is a superuser account.
147 Select or set limits for the process identified by the
150 Select display or setting of
152 (or current) resource limits.
153 If specific limits settings follow this switch, only soft limits are
154 affected unless overridden later with either the
160 Select display or setting of
162 (or maximum) resource limits.
163 If specific limits settings follow this switch, only hard limits are
164 affected until overridden later with either the
170 Select display or setting of both
176 If specific limits settings follow this switch, both soft and hard
177 limits are affected until overridden later with either the
185 formatting for output.
186 This is valid only on display mode and cannot be used when running a
188 The exact syntax used for output depends upon the type of shell from
202 A value of 0 disables core dumps.
225 The system-wide limit on the maximum number of
226 open files per process can be viewed by examining the
227 .Va kern.maxfilesperproc
230 The total number of simultaneously open files in the entire
231 system is limited to the value displayed by the
247 The system-wide limit on the maximum number of processes
248 allowed per UID can be viewed by examining the
249 .Va kern.maxprocperuid
252 The maximum number of processes that can be running simultaneously
253 in the entire system is limited to the value of the
261 This limit encompasses the entire VM space for the user process
262 and is inclusive of text, data, bss, stack,
280 in the above set of options consist of either the
287 for an infinite (or kernel-defined maximum)
288 limit, or a numeric value optionally followed by a suffix.
289 Values which relate to size default to a value in bytes, or one of the
290 following suffixes may be used as a multiplier:
292 .Bl -tag -offset indent -width 4n -compact
296 kilobytes (1024 bytes).
298 megabytes (1024*1024 bytes).
307 resource defaults to a number of seconds, but a multiplier may be
308 used, and as with size values, multiple values separated by a valid
309 suffix are added together:
311 .Bl -tag -offset indent -width 4n -compact
325 .Bl -tag -width ".Fl C Ar class"
329 to completely ignore the environment it inherits.
331 Force all resource settings to be displayed even if
332 other specific resource settings have been specified.
333 For example, if you wish to disable core dumps when starting up
334 the Usenet News system, but wish to set all other resource settings
335 as well that apply to the
337 account, you might use:
339 .Dl "eval `limits -U news -aBec 0`"
343 call, only the superuser may raise process
346 Non-root users may, however, lower them or change
349 within to any value below the hard limit.
350 When invoked to execute a program, the failure of
352 to raise a hard limit is considered a fatal error.
360 if usage is incorrect in any way; i.e., an invalid
361 option, or set/display options are selected in the same invocation,
363 is used when running a program, etc.
364 When run in display or eval mode,
366 exits with a status of
368 When run in command mode and execution of the command succeeds, the exit status
369 will be whatever the executed program returns.
384 utility does not handle commands with equal
387 names, for obvious reasons.
389 When eval output is selected, the
391 file system must be installed
392 and mounted for the shell to be correctly determined, and therefore
393 output syntax correct for the running shell.
394 The default output is valid for
396 so this means that any
399 in eval mode prior mounting
401 may only occur in standard bourne
406 utility makes no effort to ensure that resource settings emitted or displayed
407 are valid and settable by the current user.
408 Only a superuser account may raise hard limits, and when doing so
411 kernel will silently lower limits to values less than
412 specified if the values given are too high.