This usage sets limits according to limitflags, optionally sets environment variables given as name = value pairs, and then runs the specified command.
This usage determines values of resource settings according to limitflags, does not attempt to set them and outputs these values to standard output. By default, this will output the current kernel resource settings active for the calling process. Using the -C class or -U user options, you may also display the current resource settings modified by the appropriate login class resource limit entries from the login.conf(5) login capabilities database.
This usage determines values of resource settings according to limitflags, but does not set them itself. Like the previous usage, it outputs these values to standard output, except that it will emit them in eval format, suitable for the calling shell. The calling shell is determined by examining the entries in the /proc file system for the parent process. If the shell is known (i.e., it is one of sh, csh, bash, tcsh, ksh, pdksh or rc), limits emits limit or ulimit commands in the format understood by that shell. If the name of the shell cannot be determined, then the ulimit format used by sh(1) is used.
This is very useful for setting limits used by scripts, or prior launching of daemons and other background tasks with specific resource limit settings, and provides the benefit of allowing global configuration of maximum resource usage by maintaining a central database of settings in the login class database.
Within a shell script, limits will normally be used with eval within backticks as follows:
"eval limits -e -C daemon"
which causes the output of limits to be evaluated and set by the current shell.
The value of limitflags specified in the above contains one or more of the following options:
Use current resource values, modified by the resource entries applicable for the login class class.
Use current resource values, modified by the resource entries applicable to the login class the user belongs to. If user does not belong to any class, then the resource capabilities for the "default" class are used, if it exists, or the "root" class if the user is a superuser account.
Select display or setting of "soft" (or current) resource limits. If specific limits settings follow this switch, only soft limits are affected unless overridden later with either the -H or -B options.
Select display or setting of "hard" (or maximum) resource limits. If specific limits settings follow this switch, only hard limits are affected until overridden later with either the -S or -B options.
Select display or setting of both "soft" (current) or "hard" (maximum) resource limits. If specific limits settings follow this switch, both soft and hard limits are affected until overridden later with either the -S or -H options. -e Select ""eval mode"" formatting for output. This is valid only on display mode and cannot be used when running a command. The exact syntax used for output depends upon the type of shell from which limits is invoked.
Select or set the sbsize resource limit.
Select or set (if val is specified) the coredumpsize resource limit. A value of 0 disables core dumps.
Select or set (if val is specified) the datasize resource limit.
Select or set the filesize resource limit.
Select or set the memorylocked resource limit.
Select or set the memoryuse size limit.
Select or set the openfiles resource limit. The system-wide limit on the maximum number of open files per process can be viewed by examining the kern.maxfilesperprocsysctl(8) variable. The total number of simultaneously open files in the entire system is limited to the value displayed by the kern.maxfilessysctl(8) variable.
Select or set the stacksize resource limit.
Select or set the cputime resource limit.
Select or set the maxproc resource limit. The system-wide limit on the maximum number of processes allowed per UID can be viewed by examining the kern.maxprocperuidsysctl(8) variable. The maximum number of processes that can be running simultaneously in the entire system is limited to the value of the kern.maxprocsysctl(8) variable.
Select or set the virtualmem resource limit. This limit encompasses the entire VM space for the user process and is inclusive of text, data, bss, stack, brk(2), sbrk(2) and mmap 2 d space.
Valid values for val in the above set of options consist of either the string "infinity", "inf", "unlimited" or "unlimit" for an infinite (or kernel-defined maximum) limit, or a numeric value optionally followed by a suffix. Values which relate to size default to a value in bytes, or one of the following suffixes may be used as a multiplier:
512 byte blocks.
kilobytes (1024 bytes).
megabytes (1024*1024 bytes).
The cputime resource defaults to a number of seconds, but a multiplier may be used, and as with size values, multiple values separated by a valid suffix are added together:
365 day years.
Cause limits to completely ignore the environment it inherits.
Force all resource settings to be displayed even if other specific resource settings have been specified. For example, if you wish to disable core dumps when starting up the Usenet News system, but wish to set all other resource settings as well that apply to the "news" account, you might use:
"eval limits -U news -aBec 0"
As with the setrlimit(2) call, only the superuser may raise process "hard" resource limits. Non-root users may, however, lower them or change "soft" resource limits within to any value below the hard limit. When invoked to execute a program, the failure of limits to raise a hard limit is considered a fatal error.