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.
25 .Nd set or display process resource limits
28 .Op Fl C Ar class | Fl P Ar pid | Fl U Ar user
31 .Op Fl bcdfklmnopstuvw Op Ar val
33 .Op Fl C Ar class | Fl U Ar user
35 .Op Fl bcdfklmnopstuvw Op Ar val
38 .Op Ar name Ns = Ns Ar value ...
44 utility either prints or sets kernel resource limits, and may optionally set
45 environment variables like
47 and run a program with the selected resources.
51 .Bl -tag -width indent
55 .Op Ar name Ns = Ns Ar value ...
58 This usage sets limits according to
60 optionally sets environment variables given as
61 .Ar name Ns = Ns Ar value
62 pairs, and then runs the specified
64 .It Nm Op Ar limitflags
65 This usage determines values of resource settings according to
67 does not attempt to set them and outputs these values to
69 By default, this will output the current kernel resource settings
70 active for the calling process.
75 options, you may also display the current resource settings modified
76 by the appropriate login class resource limit entries from
79 login capabilities database.
80 .It Nm Fl e Op Ar limitflags
81 This usage determines values of resource settings according to
83 but does not set them.
84 Like the previous usage, it outputs these values to standard
85 output, except that it will emit them in
87 format, suitable for the calling shell.
88 If the shell is known (i.e., it is one of
89 .Nm sh , csh , bash , tcsh , ksh , pdksh
97 commands in the format understood by
99 If the name of the shell cannot be determined, then the
105 This is very useful for setting limits used by scripts, or prior
106 launching of daemons and other background tasks with specific
107 resource limit settings, and provides the benefit of allowing
108 global configuration of maximum resource usage by maintaining a
109 central database of settings in the login class database.
111 Within a shell script,
113 will normally be used with eval within backticks as follows:
115 .Dl "eval `limits -e -C daemon`"
117 which causes the output of
119 to be evaluated and set by the current shell.
124 specified in the above contains one or more of the following options:
125 .Bl -tag -width ".Fl C Ar class"
127 Use current resource values, modified by the resource entries applicable
131 Use current resource values, modified by the resource entries applicable
132 to the login class the
135 If user does not belong to any class, then the resource capabilities
138 class are used, if it exists, or the
140 class if the user is a superuser account.
142 Select or set limits for the process identified by the
145 Select display or setting of
147 (or current) resource limits.
148 If specific limits settings follow this switch, only soft limits are
149 affected unless overridden later with either the
155 Select display or setting of
157 (or maximum) resource limits.
158 If specific limits settings follow this switch, only hard limits are
159 affected until overridden later with either the
165 Select display or setting of both
171 If specific limits settings follow this switch, both soft and hard
172 limits are affected until overridden later with either the
180 formatting for output.
181 This is valid only in display mode and cannot be used when running a
183 The exact syntax used for output depends upon the type of shell from
197 A value of 0 disables core dumps.
224 The system-wide limit on the maximum number of
225 open files per process can be viewed by examining the
226 .Va kern.maxfilesperproc
229 The total number of simultaneously open files in the entire
230 system is limited to the value displayed by the
238 The limit determines the maximal number of the process-shared locks
239 which may be simultaneously created by the processes owned by the
258 The system-wide limit on the maximum number of processes
259 allowed per UID can be viewed by examining the
260 .Va kern.maxprocperuid
263 The maximum number of processes that can be running simultaneously
264 in the entire system is limited to the value of the
272 This limit encompasses the entire VM space for the user process
273 and is inclusive of text, data, bss, stack,
287 in the above set of options consist of either the
294 for an infinite (or kernel-defined maximum)
295 limit, or a numeric value optionally followed by a suffix.
296 Values which relate to size default to a value in bytes, or one of the
297 following suffixes may be used as a multiplier:
299 .Bl -tag -offset indent -width 4n -compact
303 kilobytes (1024 bytes).
305 megabytes (1024*1024 bytes).
314 resource defaults to a number of seconds, but a multiplier may be
315 used, and as with size values, multiple values separated by a valid
316 suffix are added together:
318 .Bl -tag -offset indent -width 4n -compact
332 .Bl -tag -width ".Fl C Ar class"
336 to completely ignore the environment it inherits.
338 Force all resource settings to be displayed even if
339 other specific resource settings have been specified.
340 For example, if you wish to disable core dumps when starting up
341 the Usenet News system, but wish to set all other resource settings
342 as well that apply to the
344 account, you might use:
346 .Dl "eval `limits -U news -aBec 0`"
350 call, only the superuser may raise process
353 Non-root users may, however, lower them or change
356 within to any value below the hard limit.
357 When invoked to execute a program, the failure of
359 to raise a hard limit is considered a fatal error.
367 if usage is incorrect in any way; i.e., an invalid
368 option, or set/display options are selected in the same invocation,
370 is used when running a program, etc.
371 When run in display or eval mode,
373 exits with a status of
375 When run in command mode and execution of the command succeeds, the exit status
376 will be whatever the executed program returns.
378 Show current stack size limit:
379 .Bd -literal -offset indent
381 Resource limits (current):
390 .Bd -literal -offset indent
392 Data segment size exceeds process limit
401 Output obtained when command is run from
403 .Bd -literal -offset indent
410 .Bd -literal -offset indent
429 utility first appeared in
434 utility was written by
435 .An David Nugent Aq Mt davidn@FreeBSD.org .
439 utility does not handle commands with equal
442 names, for obvious reasons.
446 utility makes no effort to ensure that resource settings emitted or displayed
447 are valid and settable by the current user.
448 Only a superuser account may raise hard limits, and when doing so
451 kernel will silently lower limits to values less than
452 specified if the values given are too high.