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 bcdfklmnstuvpw Op Ar val
35 .Op Fl C Ar class | Fl U Ar user
37 .Op Fl bcdfklmnstuvpw 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 If the shell is known (i.e., it is one of
91 .Nm sh , csh , bash , tcsh , ksh , pdksh
99 commands in the format understood by
101 If the name of the shell cannot be determined, then the
107 This is very useful for setting limits used by scripts, or prior
108 launching of daemons and other background tasks with specific
109 resource limit settings, and provides the benefit of allowing
110 global configuration of maximum resource usage by maintaining a
111 central database of settings in the login class database.
113 Within a shell script,
115 will normally be used with eval within backticks as follows:
117 .Dl "eval `limits -e -C daemon`"
119 which causes the output of
121 to be evaluated and set by the current shell.
126 specified in the above contains one or more of the following options:
127 .Bl -tag -width ".Fl C Ar class"
129 Use current resource values, modified by the resource entries applicable
133 Use current resource values, modified by the resource entries applicable
134 to the login class the
137 If user does not belong to any class, then the resource capabilities
140 class are used, if it exists, or the
142 class if the user is a superuser account.
144 Select or set limits for the process identified by the
147 Select display or setting of
149 (or current) resource limits.
150 If specific limits settings follow this switch, only soft limits are
151 affected unless overridden later with either the
157 Select display or setting of
159 (or maximum) resource limits.
160 If specific limits settings follow this switch, only hard limits are
161 affected until overridden later with either the
167 Select display or setting of both
173 If specific limits settings follow this switch, both soft and hard
174 limits are affected until overridden later with either the
182 formatting for output.
183 This is valid only on display mode and cannot be used when running a
185 The exact syntax used for output depends upon the type of shell from
199 A value of 0 disables core dumps.
226 The system-wide limit on the maximum number of
227 open files per process can be viewed by examining the
228 .Va kern.maxfilesperproc
231 The total number of simultaneously open files in the entire
232 system is limited to the value displayed by the
248 The system-wide limit on the maximum number of processes
249 allowed per UID can be viewed by examining the
250 .Va kern.maxprocperuid
253 The maximum number of processes that can be running simultaneously
254 in the entire system is limited to the value of the
262 This limit encompasses the entire VM space for the user process
263 and is inclusive of text, data, bss, stack,
281 in the above set of options consist of either the
288 for an infinite (or kernel-defined maximum)
289 limit, or a numeric value optionally followed by a suffix.
290 Values which relate to size default to a value in bytes, or one of the
291 following suffixes may be used as a multiplier:
293 .Bl -tag -offset indent -width 4n -compact
297 kilobytes (1024 bytes).
299 megabytes (1024*1024 bytes).
308 resource defaults to a number of seconds, but a multiplier may be
309 used, and as with size values, multiple values separated by a valid
310 suffix are added together:
312 .Bl -tag -offset indent -width 4n -compact
326 .Bl -tag -width ".Fl C Ar class"
330 to completely ignore the environment it inherits.
332 Force all resource settings to be displayed even if
333 other specific resource settings have been specified.
334 For example, if you wish to disable core dumps when starting up
335 the Usenet News system, but wish to set all other resource settings
336 as well that apply to the
338 account, you might use:
340 .Dl "eval `limits -U news -aBec 0`"
344 call, only the superuser may raise process
347 Non-root users may, however, lower them or change
350 within to any value below the hard limit.
351 When invoked to execute a program, the failure of
353 to raise a hard limit is considered a fatal error.
361 if usage is incorrect in any way; i.e., an invalid
362 option, or set/display options are selected in the same invocation,
364 is used when running a program, etc.
365 When run in display or eval mode,
367 exits with a status of
369 When run in command mode and execution of the command succeeds, the exit status
370 will be whatever the executed program returns.
385 utility does not handle commands with equal
388 names, for obvious reasons.
392 utility makes no effort to ensure that resource settings emitted or displayed
393 are valid and settable by the current user.
394 Only a superuser account may raise hard limits, and when doing so
397 kernel will silently lower limits to values less than
398 specified if the values given are too high.