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 bcdfklmnopstuvw Op Ar val
35 .Op Fl C Ar class | Fl U Ar user
37 .Op Fl bcdfklmnopstuvw 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.
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 in 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
240 The limit determines the maximal number of the process-shared locks
241 which may be simultaneously created by the processes owned by the
260 The system-wide limit on the maximum number of processes
261 allowed per UID can be viewed by examining the
262 .Va kern.maxprocperuid
265 The maximum number of processes that can be running simultaneously
266 in the entire system is limited to the value of the
274 This limit encompasses the entire VM space for the user process
275 and is inclusive of text, data, bss, stack,
289 in the above set of options consist of either the
296 for an infinite (or kernel-defined maximum)
297 limit, or a numeric value optionally followed by a suffix.
298 Values which relate to size default to a value in bytes, or one of the
299 following suffixes may be used as a multiplier:
301 .Bl -tag -offset indent -width 4n -compact
305 kilobytes (1024 bytes).
307 megabytes (1024*1024 bytes).
316 resource defaults to a number of seconds, but a multiplier may be
317 used, and as with size values, multiple values separated by a valid
318 suffix are added together:
320 .Bl -tag -offset indent -width 4n -compact
334 .Bl -tag -width ".Fl C Ar class"
338 to completely ignore the environment it inherits.
340 Force all resource settings to be displayed even if
341 other specific resource settings have been specified.
342 For example, if you wish to disable core dumps when starting up
343 the Usenet News system, but wish to set all other resource settings
344 as well that apply to the
346 account, you might use:
348 .Dl "eval `limits -U news -aBec 0`"
352 call, only the superuser may raise process
355 Non-root users may, however, lower them or change
358 within to any value below the hard limit.
359 When invoked to execute a program, the failure of
361 to raise a hard limit is considered a fatal error.
369 if usage is incorrect in any way; i.e., an invalid
370 option, or set/display options are selected in the same invocation,
372 is used when running a program, etc.
373 When run in display or eval mode,
375 exits with a status of
377 When run in command mode and execution of the command succeeds, the exit status
378 will be whatever the executed program returns.
393 utility does not handle commands with equal
396 names, for obvious reasons.
400 utility makes no effort to ensure that resource settings emitted or displayed
401 are valid and settable by the current user.
402 Only a superuser account may raise hard limits, and when doing so
405 kernel will silently lower limits to values less than
406 specified if the values given are too high.