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
33 .Op Fl cdflmnstu Op val
37 .Op Fl cdflmnstu Op val
39 .Op Ar name Ns = Ns Ar value ...
45 .Op Fl cdflmnstu Op val
49 .Op Fl cdflmnstu Op val
51 .Op Ar name Ns = Ns Ar value ...
56 utility either prints or sets kernel resource limits, and may optionally set
57 environment variables like
59 and run a program with the selected resources.
64 .Bl -tag -width indent
68 .Op Ar name Ns = Ns Ar value
71 This usage sets limits according to
73 optionally sets environment variables given as
74 .Ar name Ns = Ns Ar value
75 pairs, and then runs the specified command.
80 This usage determines values of resource settings according to
82 does not attempt to set them and outputs these values to
84 By default, this will output the current kernel resource settings
85 active for the calling process.
90 flags, you may also display the current resource settings modified
91 by the appropriate login class resource limit entries from
94 login capabilities database.
97 .Fl e Op Ar limitflags
99 This usage determines values of resource settings according to
101 but does not set them itself.
102 Like the previous usage it outputs these values to standard
103 output, except that it will emit them in
105 format, suitable for the calling shell.
106 The calling shell is determined by examining the entries in the
108 filesystem for the parent process.
109 If the shell is known (i.e. it is one of sh, csh, bash, tcsh, ksh,
112 emits 'limit' or 'ulimit' commands in the format understood by
114 If the name of the shell cannot be determined, then the 'ulimit'
119 This is very useful for setting limits used by scripts, or prior
120 launching of daemons and other background tasks with specific
121 resource limit settings, and provides the benefit of allowing
122 global configuration of maximum resource usage by maintaining a
123 central database of settings in the login class database.
125 Within a shell script,
127 will normally be used with eval within backticks as follows:
129 .Dl eval `limits -e -C daemon`
131 which causes the output of
133 to be evaluated and set by the current shell.
136 The value of limitflags specified in the above contains one or more of the
139 .Bl -tag -width "-d [limit]"
141 Use current resource values, modified by the resource entries applicable
142 for the login class "class".
144 Use current resource values, modified by the resource entries applicable
145 to the login class which "user" belongs to.
146 If the user does not belong to a class, then the resource capabilities
147 for the "default" class are used, if it exists, or the "root" class if
148 the user is a superuser account.
150 Select display or setting of "soft" (or current) resource limits.
151 If specific limits settings follow this switch, only soft limits are
152 affected unless overridden later with either the
158 Select display or setting of "hard" (or maximum) resource limits.
159 If specific limits settings follow this switch, only hard limits are
160 affected until overridden later with either the
166 Select display or setting of both "soft" (current) or "hard" (maximum)
168 If specific limits settings follow this switch, both soft and hard
169 limits are affected until overridden later with either the
175 Select "eval mode" formatting for output.
176 This is valid only on display mode and cannot be used when running a
178 The exact syntax used for output depends upon the type of shell from
187 Select or set (if 'limit' is specified) the
190 A value of 0 disables core dumps.
192 Select or set (if 'limit' is specified) the
210 resource limit. The system-wide limit on the maximum number of
211 open files per process can be viewed using the 'sysctl kern.maxfilesperproc'
212 command. The total number of simultaneously open files in the entire
213 system is limited to the value displayed by the 'sysctl kern.maxfiles'
226 resource limit. The system-wide limit on the maximum number of processes
227 allowed per UID can be viewed using the 'sysctl kern.maxprocperuid' command.
228 The maximum number of processes that can be running simultaneously
229 in the entire system is limited to the value given by
230 the 'sysctl kern.maxproc' command.
234 in the above set of flags consist of either the
241 for an infinite (or kernel-defined maximum)
242 limit, or a numeric value maybe followed by a suffix.
243 Values which relate to size default to a value in bytes, or one of the
244 following suffixes may be used as a multiplier:
246 .Bl -tag -offset indent -width "xxxx" -compact
250 kilobytes (1024 bytes).
252 megabytes (1024*1024 bytes).
261 resource defaults to a number of seconds, but a multiplier may be
262 used, and as with size values, multiple values separated by a valid
263 suffix are added together:
264 .Bl -tag -offset indent -width "xxxx" -compact
284 to completely ignore the environment it inherits.
286 This option forces all resource settings to be displayed even if
287 other specific resource settings have been specified.
288 For example, if you wish to disable core dumps when starting up
289 the usenet news system, but wish to set all other resource settings
290 as well that apply to the 'news' account, you might use:
292 .Dl eval `limits -U news -aBec 0`
296 call, only the superuser may raise process "hard" resource limits.
297 Non-root users may, however, lower them or change "soft" resource limits
298 within to any value below the hard limit.
299 When invoked to execute a program, the failure of
301 to raise a hard limit is considered a fatal error.
307 exits with EXIT_FAILURE if usage is incorrect in any way; i.e. an invalid
308 option, or set/display options are selected in the same invocation,
310 is used when running a program, etc.
311 When run in display or eval mode,
313 exits with a status of EXIT_SUCCESS.
314 When run in command mode and execution of the command succeeds, the exit status
315 will be whatever the executed program returns.
329 utility does not handle commands with equal (``='') signs in their
330 names, for obvious reasons.
332 When eval output is selected, the
334 filesystem must be installed
335 and mounted for the shell to be correctly determined, and therefore
336 output syntax correct for the running shell.
337 The default output is valid for
339 so this means that any
342 in eval mode prior mounting
344 may only occur in standard bourne
349 utility makes no effort to ensure that resource settings emitted or displayed
350 are valid and settable by the current user.
351 Only a superuser account may raise hard limits, and when doing so
354 kernel will silently lower limits to values less than
355 specified if the values given are too high.