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.
22 .Dd September 18, 2002
27 .Nd set or display process resource limits
30 .Op Fl C Ar class | Fl U Ar user
33 .Op Fl bcdflmnstuvp Op Ar val
35 .Op Fl C Ar class | Fl U Ar user
37 .Op Fl bcdflmnstuvp 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 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.
222 The system-wide limit on the maximum number of
223 open files per process can be viewed by examining the
224 .Va kern.maxfilesperproc
227 The total number of simultaneously open files in the entire
228 system is limited to the value displayed by the
244 The system-wide limit on the maximum number of processes
245 allowed per UID can be viewed by examining the
246 .Va kern.maxprocperuid
249 The maximum number of processes that can be running simultaneously
250 in the entire system is limited to the value of the
258 This limit encompasses the entire VM space for the user process
259 and is inclusive of text, data, bss, stack,
273 in the above set of options consist of either the
280 for an infinite (or kernel-defined maximum)
281 limit, or a numeric value optionally followed by a suffix.
282 Values which relate to size default to a value in bytes, or one of the
283 following suffixes may be used as a multiplier:
285 .Bl -tag -offset indent -width 4n -compact
289 kilobytes (1024 bytes).
291 megabytes (1024*1024 bytes).
300 resource defaults to a number of seconds, but a multiplier may be
301 used, and as with size values, multiple values separated by a valid
302 suffix are added together:
304 .Bl -tag -offset indent -width 4n -compact
318 .Bl -tag -width ".Fl C Ar class"
322 to completely ignore the environment it inherits.
324 Force all resource settings to be displayed even if
325 other specific resource settings have been specified.
326 For example, if you wish to disable core dumps when starting up
327 the Usenet News system, but wish to set all other resource settings
328 as well that apply to the
330 account, you might use:
332 .Dl "eval `limits -U news -aBec 0`"
336 call, only the superuser may raise process
339 Non-root users may, however, lower them or change
342 within to any value below the hard limit.
343 When invoked to execute a program, the failure of
345 to raise a hard limit is considered a fatal error.
353 if usage is incorrect in any way; i.e., an invalid
354 option, or set/display options are selected in the same invocation,
356 is used when running a program, etc.
357 When run in display or eval mode,
359 exits with a status of
361 When run in command mode and execution of the command succeeds, the exit status
362 will be whatever the executed program returns.
376 utility does not handle commands with equal
379 names, for obvious reasons.
381 When eval output is selected, the
383 file system must be installed
384 and mounted for the shell to be correctly determined, and therefore
385 output syntax correct for the running shell.
386 The default output is valid for
388 so this means that any
391 in eval mode prior mounting
393 may only occur in standard bourne
398 utility makes no effort to ensure that resource settings emitted or displayed
399 are valid and settable by the current user.
400 Only a superuser account may raise hard limits, and when doing so
403 kernel will silently lower limits to values less than
404 specified if the values given are too high.