LIMITS(1)

NAME
limits - Set or display process resource limits

SYNOPSIS
limits [-C class | -U user] [-SHB] [-e] [-cdflmnstu [val]]
limits [-C class | -U user] [-SHB] [-cdflmnstu [val]] [-E] [name=value ...] [command]

DESCRIPTION
Limits ether prints or sets kernel resource limits, and may optionally set environment variables like env(1) and run a program with the selected resources. Three uses of the limits command are possible:

limits [limitflags]
    [name=value] command

    This usage sets limits according to limitflags, optionally sets environment variables given as name=value pairs, and then runs the specified command.

limits [limitflags]

    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 flags, you may also display the current resource settings modified by the the appropriate login class resource limit entries from the login.conf(5) login capabilities database.

limits -e [limitflags]

    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 filesystem for the parent process. If the shell is known (ie. 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 /bin/sh 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:

-C class
    Use current resource values, modified by the resource entries applicable for the login class "class".

-U user
    Use current resource values, modified by the resource entries applicable to the login class which "user" belongs to. If the user does not belong to a 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.

-S  Selects 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 flags.

-H  Selects 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 flags.

-B  Selects 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 flags. -e Selects "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 depeneds upon the type of shell from which limits is invoked.

-c [limit]
    Selects or sets (if 'limit' is specified) the coredumsize resource limit. A value of 0 disables core dumps.

-d [limit]
    Selects or sets (if 'limit' is specified) the datasize resource limit.

-f [limit]
    Selects or sets the filesize resource limit.

-l [limit]
    Selects or sets the memorylocked resource limit.

-m [limit]
    Selects or sets the memoryuse size limit

-n [limit]
    Selects or sets the openfiles resource limit.

-s [limit]
    Selects or sets the stacksize resource limit.

-t [limit]
    Selects or sets the cputime resource limit.

-u [limit]
    Selects or sets the maxproc resource limit.

    Valid values for 'limit' in the above set of flags consist of either the string 'infinity' or 'inf' for an infinite (or kernel-defined maximum) limit, or a numeric value maybe 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:

    b   512 byte blocks.
    k   kilobytes (1024 bytes).
    m   megabytes (1024*1024 bytes).
    g   gigabytes.
    t   terrabytes.

    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:
    s   seconds.
    m   minutes.
    h   hours.
    d   days.
    w   weeks.
    y   365 day years.

-E  The option ‘-E’ causes limits to completely ignore the environment it inherits.

-a  This option forces 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(3) 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.

DIAGNOSTICS
Limits exits with EXIT_FAILURE if usage is incorrect in any way; ie. an invalid option, or set/display options are selected in the same invocation, -e is used when running a program, etc. When run in display or eval mode, limits exits with with a status of EXIT_SUCCESS. When run in command mode and execution of the command succeeds, the exit status will be whatever the executed program returns.

SEE ALSO
csh(1), env(1), limit(1), sh(1), ulimit(1), getrlimit(3), setrlimit(3), login_cap(3), login.conf(5)

BUGS
Limits does not handle commands with equal (``='') signs in their names, for obvious reasons.

When eval output is selected, the /proc filesystem must be installed and mounted for the shell to be correctly determined, and therefore output syntax correct for the running shell. The default output is valid for /bin/sh, so this means that any usage of limits in eval mode prior mounting /proc may only occur in standard bourne shell scripts.

Limits makes no effort to ensure that resource settings emitted or displayed are valid and settable by the current user. Only a superuser account may raise hard limits, and and when doing so the FreeBSD kernel will silently lower limits to values less than specified if the values given are too high.