]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - usr.bin/limits/limits.1
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / usr.bin / limits / limits.1
1 .\" Copyright (c) 1996 David Nugent <davidn@blaze.net.au>
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, is permitted provided that the following conditions
6 .\" are met:
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
16 .\"    David Nugent.
17 .\" 5. Modifications may be freely made to this file providing the above
18 .\"    conditions are met.
19 .\"
20 .\" $FreeBSD$
21 .\"
22 .Dd January 23, 2012
23 .Dt LIMITS 1
24 .Os
25 .Sh NAME
26 .Nm limits
27 .Nd set or display process resource limits
28 .Sh SYNOPSIS
29 .Nm
30 .Op Fl C Ar class | Fl P Ar pid | Fl U Ar user
31 .Op Fl SHB
32 .Op Fl ea
33 .Op Fl bcdflmnstuvpw Op Ar val
34 .Nm
35 .Op Fl C Ar class | Fl U Ar user
36 .Op Fl SHB
37 .Op Fl bcdflmnstuvpw Op Ar val
38 .Op Fl E
39 .Oo
40 .Op Ar name Ns = Ns Ar value ...
41 .Ar command
42 .Oc
43 .Sh DESCRIPTION
44 The
45 .Nm
46 utility either prints or sets kernel resource limits, and may optionally set
47 environment variables like
48 .Xr env 1
49 and run a program with the selected resources.
50 Three uses of the
51 .Nm
52 utility are possible:
53 .Bl -tag -width indent
54 .It Xo
55 .Nm
56 .Op Ar limitflags
57 .Op Ar name Ns = Ns Ar value ...
58 .Ar command
59 .Xc
60 This usage sets limits according to
61 .Ar limitflags ,
62 optionally sets environment variables given as
63 .Ar name Ns = Ns Ar value
64 pairs, and then runs the specified
65 .Ar command .
66 .It Nm Op Ar limitflags
67 This usage determines values of resource settings according to
68 .Ar limitflags ,
69 does not attempt to set them and outputs these values to
70 standard output.
71 By default, this will output the current kernel resource settings
72 active for the calling process.
73 Using the
74 .Fl C Ar class
75 or
76 .Fl U Ar user
77 options, you may also display the current resource settings modified
78 by the appropriate login class resource limit entries from
79 the
80 .Xr login.conf 5
81 login capabilities database.
82 .It Nm Fl e Op Ar limitflags
83 This usage determines values of resource settings according to
84 .Ar limitflags ,
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
88 .Ic eval
89 format, suitable for the calling shell.
90 The calling shell is determined by examining the entries in the
91 .Pa /proc
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
95 or
96 .Nm rc ) ,
97 .Nm
98 emits
99 .Ic limit
100 or
101 .Ic ulimit
102 commands in the format understood by
103 that shell.
104 If the name of the shell cannot be determined, then the
105 .Ic ulimit
106 format used by
107 .Xr sh 1
108 is used.
109 .Pp
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.
115 .Pp
116 Within a shell script,
117 .Nm
118 will normally be used with eval within backticks as follows:
119 .Pp
120 .Dl "eval `limits -e -C daemon`"
121 .Pp
122 which causes the output of
123 .Nm
124 to be evaluated and set by the current shell.
125 .El
126 .Pp
127 The value of
128 .Ar limitflags
129 specified in the above contains one or more of the following options:
130 .Bl -tag -width ".Fl C Ar class"
131 .It Fl C Ar class
132 Use current resource values, modified by the resource entries applicable
133 for the login class
134 .Ar class .
135 .It Fl U Ar user
136 Use current resource values, modified by the resource entries applicable
137 to the login class the
138 .Ar user
139 belongs to.
140 If user does not belong to any class, then the resource capabilities
141 for the
142 .Dq Li default
143 class are used, if it exists, or the
144 .Dq Li root
145 class if the user is a superuser account.
146 .It Fl P Ar pid
147 Select or set limits for the process identified by the
148 .Ar pid .
149 .It Fl S
150 Select display or setting of
151 .Dq soft
152 (or current) resource limits.
153 If specific limits settings follow this switch, only soft limits are
154 affected unless overridden later with either the
155 .Fl H
156 or
157 .Fl B
158 options.
159 .It Fl H
160 Select display or setting of
161 .Dq hard
162 (or maximum) resource limits.
163 If specific limits settings follow this switch, only hard limits are
164 affected until overridden later with either the
165 .Fl S
166 or
167 .Fl B
168 options.
169 .It Fl B
170 Select display or setting of both
171 .Dq soft
172 (current) or
173 .Dq hard
174 (maximum)
175 resource limits.
176 If specific limits settings follow this switch, both soft and hard
177 limits are affected until overridden later with either the
178 .Fl S
179 or
180 .Fl H
181 options.
182 .It Fl e
183 Select
184 .Dq "eval mode"
185 formatting for output.
186 This is valid only on display mode and cannot be used when running a
187 command.
188 The exact syntax used for output depends upon the type of shell from
189 which
190 .Nm
191 is invoked.
192 .It Fl b Op Ar val
193 Select or set the
194 .Va sbsize
195 resource limit.
196 .It Fl c Op Ar val
197 Select or set (if
198 .Ar val
199 is specified) the
200 .Va coredumpsize
201 resource limit.
202 A value of 0 disables core dumps.
203 .It Fl d Op Ar val
204 Select or set (if
205 .Ar val
206 is specified) the
207 .Va datasize
208 resource limit.
209 .It Fl f Op Ar val
210 Select or set the
211 .Va filesize
212 resource limit.
213 .It Fl l Op Ar val
214 Select or set the
215 .Va memorylocked
216 resource limit.
217 .It Fl m Op Ar val
218 Select or set the
219 .Va memoryuse
220 size limit.
221 .It Fl n Op Ar val
222 Select or set the
223 .Va openfiles
224 resource limit.
225 The system-wide limit on the maximum number of
226 open files per process can be viewed by examining the
227 .Va kern.maxfilesperproc
228 .Xr sysctl 8
229 variable.
230 The total number of simultaneously open files in the entire
231 system is limited to the value displayed by the
232 .Va kern.maxfiles
233 .Xr sysctl 8
234 variable.
235 .It Fl s Op Ar val
236 Select or set the
237 .Va stacksize
238 resource limit.
239 .It Fl t Op Ar val
240 Select or set the
241 .Va cputime
242 resource limit.
243 .It Fl u Op Ar val
244 Select or set the
245 .Va maxproc
246 resource limit.
247 The system-wide limit on the maximum number of processes
248 allowed per UID can be viewed by examining the
249 .Va kern.maxprocperuid
250 .Xr sysctl 8
251 variable.
252 The maximum number of processes that can be running simultaneously
253 in the entire system is limited to the value of the
254 .Va kern.maxproc
255 .Xr sysctl 8
256 variable.
257 .It Fl v Op Ar val
258 Select or set the
259 .Va virtualmem
260 resource limit.
261 This limit encompasses the entire VM space for the user process
262 and is inclusive of text, data, bss, stack,
263 .Xr brk 2 ,
264 .Xr sbrk 2
265 and
266 .Xr mmap 2 Ns 'd
267 space.
268 .It Fl p Op Ar val
269 Select or set the
270 .Va pseudoterminals
271 resource limit.
272 .It Fl w Op Ar val
273 Select or set the
274 .Va swapuse
275 resource limit.
276 .El
277 .Pp
278 Valid values for
279 .Ar val
280 in the above set of options consist of either the
281 string
282 .Dq Li infinity ,
283 .Dq Li inf ,
284 .Dq Li unlimited
285 or
286 .Dq Li unlimit
287 for an infinite (or kernel-defined maximum)
288 limit, or a numeric value optionally followed by a suffix.
289 Values which relate to size default to a value in bytes, or one of the
290 following suffixes may be used as a multiplier:
291 .Pp
292 .Bl -tag -offset indent -width 4n -compact
293 .It Li b
294 512 byte blocks.
295 .It Li k
296 kilobytes (1024 bytes).
297 .It Li m
298 megabytes (1024*1024 bytes).
299 .It Li g
300 gigabytes.
301 .It Li t
302 terabytes.
303 .El
304 .Pp
305 The
306 .Va cputime
307 resource defaults to a number of seconds, but a multiplier may be
308 used, and as with size values, multiple values separated by a valid
309 suffix are added together:
310 .Pp
311 .Bl -tag -offset indent -width 4n -compact
312 .It Li s
313 seconds.
314 .It Li m
315 minutes.
316 .It Li h
317 hours.
318 .It Li d
319 days.
320 .It Li w
321 weeks.
322 .It Li y
323 365 day years.
324 .El
325 .Bl -tag -width ".Fl C Ar class"
326 .It Fl E
327 Cause
328 .Nm
329 to completely ignore the environment it inherits.
330 .It Fl a
331 Force all resource settings to be displayed even if
332 other specific resource settings have been specified.
333 For example, if you wish to disable core dumps when starting up
334 the Usenet News system, but wish to set all other resource settings
335 as well that apply to the
336 .Dq Li news
337 account, you might use:
338 .Pp
339 .Dl "eval `limits -U news -aBec 0`"
340 .Pp
341 As with the
342 .Xr setrlimit 2
343 call, only the superuser may raise process
344 .Dq hard
345 resource limits.
346 Non-root users may, however, lower them or change
347 .Dq soft
348 resource limits
349 within to any value below the hard limit.
350 When invoked to execute a program, the failure of
351 .Nm
352 to raise a hard limit is considered a fatal error.
353 .El
354 .Sh EXIT STATUS
355 The
356 .Nm
357 utility
358 exits with
359 .Dv EXIT_FAILURE
360 if usage is incorrect in any way; i.e., an invalid
361 option, or set/display options are selected in the same invocation,
362 .Fl e
363 is used when running a program, etc.
364 When run in display or eval mode,
365 .Nm
366 exits with a status of
367 .Dv EXIT_SUCCESS .
368 When run in command mode and execution of the command succeeds, the exit status
369 will be whatever the executed program returns.
370 .Sh SEE ALSO
371 .Xr csh 1 ,
372 .Xr env 1 ,
373 .Xr limit 1 ,
374 .Xr sh 1 ,
375 .Xr getrlimit 2 ,
376 .Xr setrlimit 2 ,
377 .Xr login_cap 3 ,
378 .Xr login.conf 5 ,
379 .Xr rctl 8 ,
380 .Xr sysctl 8
381 .Sh BUGS
382 The
383 .Nm
384 utility does not handle commands with equal
385 .Pq Ql =
386 signs in their
387 names, for obvious reasons.
388 .Pp
389 When eval output is selected, the
390 .Pa /proc
391 file system must be installed
392 and mounted for the shell to be correctly determined, and therefore
393 output syntax correct for the running shell.
394 The default output is valid for
395 .Xr sh 1 ,
396 so this means that any
397 usage of
398 .Nm
399 in eval mode prior mounting
400 .Pa /proc
401 may only occur in standard bourne
402 shell scripts.
403 .Pp
404 The
405 .Nm
406 utility makes no effort to ensure that resource settings emitted or displayed
407 are valid and settable by the current user.
408 Only a superuser account may raise hard limits, and when doing so
409 the
410 .Fx
411 kernel will silently lower limits to values less than
412 specified if the values given are too high.