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
45 .Op Fl cdflmnstu Op val
49 .Op Fl cdflmnstu Op val
55 either prints or sets kernel resource limits, and may optionally set
56 environment variables like
58 and run a program with the selected resources.
63 .Bl -hang -width indent
64 .It Nm limits Op Ar limitflags
68 This usage sets limits according to
70 optionally sets environment variables given as
72 pairs, and then runs the specified command.
73 .It Nm limits Op Ar limitflags
75 This usage determines values of resource settings according to
77 does not attempt to set them and outputs these values to
79 By default, this will output the current kernel resource settings
80 active for the calling process.
85 flags, you may also display the current resource settings modified
86 by the the appropriate login class resource limit entries from
89 login capabilities database.
90 .It Nm limits Fl e Op Ar limitflags
92 This usage determines values of resource settings according to
94 but does not set them itself.
95 Like the previous usage it outputs these values to standard
96 output, except that it will emit them in
98 format, suitable for the calling shell.
99 The calling shell is determined by examining the entries in the
101 filesystem for the parent process.
102 If the shell is known (ie. it is one of sh, csh, bash, tcsh, ksh,
105 emits 'limit' or 'ulimit' commands in the format understood by
107 If the name of the shell cannot be determined, then the 'ulimit'
112 This is very useful for setting limits used by scripts, or prior
113 launching of daemons and other background tasks with specific
114 resource limit settings, and provides the benefit of allowing
115 global configuration of maximum resource usage by maintaining a
116 central database of settings in the login class database.
118 Within a shell script,
120 will normally be used with eval within backticks as follows:
122 .Dl eval `limits -e -C daemon`
124 which causes the output of
126 to be evaluated and set by the current shell.
129 The value of limitflags specified in the above contains one or more of the
132 .Bl -tag -width "-d [limit]"
134 Use current resource values, modified by the resource entries applicable
135 for the login class "class".
137 Use current resource values, modified by the resource entries applicable
138 to the login class which "user" belongs to.
139 If the user does not belong to a class, then the resource capabilities
140 for the "default" class are used, if it exists, or the "root" class if
141 the user is a superuser account.
143 Selects display or setting of "soft" (or current) resource limits.
144 If specific limits settings follow this switch, only soft limits are
145 affected unless overridden later with either the
151 Selects display or setting of "hard" (or maximum) resource limits.
152 If specific limits settings follow this switch, only hard limits are
153 affected until overridden later with either the
159 Selects display or setting of both "soft" (current) or "hard" (maximum)
161 If specific limits settings follow this switch, both soft and hard
162 limits are affected until overridden later with either the
168 Selects "eval mode" formatting for output.
169 This is valid only on display mode and cannot be used when running a
171 The exact syntax used for output depends upon the type of shell from
180 Selects or sets (if 'limit' is specified) the
183 A value of 0 disables core dumps.
185 Selects or sets (if 'limit' is specified) the
203 resource limit. The system-wide limit on the maximum number of
204 open files per process can be viewed using the 'sysctl kern.maxfilesperproc'
205 command. The total number of simultaneously open files in the entire
206 system is limited to the value displayed by the 'sysctl kern.maxfiles'
219 resource limit. The system-wide limit on the maximum number of processes
220 allowed per UID can be viewed using the 'sysctl kern.maxprocperuid' command.
221 The maximum number of processes that can be running simultaneously
222 in the entire system is limited to the value given by
223 the 'sysctl kern.maxproc' command.
225 Valid values for 'limit' in the above set of flags consist of either the
226 string 'infinity' or 'inf' for an infinite (or kernel-defined maximum)
227 limit, or a numeric value maybe followed by a suffix.
228 Values which relate to size default to a value in bytes, or one of the
229 following suffixes may be used as a multiplier:
231 .Bl -tag -offset indent -width "xxxx" -compact
235 kilobytes (1024 bytes).
237 megabytes (1024*1024 bytes).
246 resource defaults to a number of seconds, but a multiplier may be
247 used, and as with size values, multiple values separated by a valid
248 suffix are added together:
249 .Bl -tag -offset indent -width "xxxx" -compact
269 to completely ignore the environment it inherits.
271 This option forces all resource settings to be displayed even if
272 other specific resource settings have been specified.
273 For example, if you wish to disable core dumps when starting up
274 the usenet news system, but wish to set all other resource settings
275 as well that apply to the 'news' account, you might use:
277 .Dl eval `limits -U news -aBec 0`
281 call, only the superuser may raise process "hard" resource limits.
282 Non-root users may, however, lower them or change "soft" resource limits
283 within to any value below the hard limit.
284 When invoked to execute a program, the failure of
286 to raise a hard limit is considered a fatal error.
290 exits with EXIT_FAILURE if usage is incorrect in any way; ie. an invalid
291 option, or set/display options are selected in the same invocation,
293 is used when running a program, etc.
294 When run in display or eval mode,
296 exits with a status of EXIT_SUCCESS.
297 When run in command mode and execution of the command succeeds, the exit status
298 will be whatever the executed program returns.
311 does not handle commands with equal (``='') signs in their
312 names, for obvious reasons.
314 When eval output is selected, the /proc filesystem must be installed
315 and mounted for the shell to be correctly determined, and therefore
316 output syntax correct for the running shell.
317 The default output is valid for /bin/sh, so this means that any
320 in eval mode prior mounting /proc may only occur in standard bourne
324 makes no effort to ensure that resource settings emitted or displayed
325 are valid and settable by the current user.
326 Only a superuser account may raise hard limits, and when doing so
327 the FreeBSD kernel will silently lower limits to values less than
328 specified if the values given are too high.