HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

posix_setrlimit

Description

The posix_setrlimit of POSIX for PHP sets the system resource limits.

Syntax

posix_setrlimit(
    int $resource,
    int $soft_limit,
    int $hard_limit
): bool

Parameters

resource

The resource limit constant corresponding to the limit that is being set.

ConstantDescription
POSIX_RLIMIT_ASThe maximum size of the process's address space in bytes. See also PHP's memory_limit configuration directive.
POSIX_RLIMIT_COREThe maximum size of a core file. If the limit is set to 0, no core file will be generated.
POSIX_RLIMIT_CPUThe maximum amount of CPU time that the process can use, in seconds. When the soft limit is hit, a SIGXCPU signal will be sent, which can be caught with pcntl_signal(). Depending on the operating system, additional SIGXCPU signals may be sent each second until the hard limit is hit, at which point an uncatchable SIGKILL signal is sent. See also set_time_limit().
POSIX_RLIMIT_DATAThe maximum size of the process's data segment, in bytes. It is extremely unlikely that this will have any effect on the execution of PHP unless an extension is in use that calls brk() or sbrk().
POSIX_RLIMIT_FSIZEThe maximum size of files that the process can create, in bytes.
POSIX_RLIMIT_LOCKSThe maximum number of locks that the process can create. This is only supported on extremely old Linux kernels.
POSIX_RLIMIT_MEMLOCKThe maximum number of bytes that can be locked into memory.
POSIX_RLIMIT_MSGQUEUEThe maximum number of bytes that can be allocated for POSIX message queues. PHP does not ship with support for POSIX message queues, so this limit will not have any effect unless you are using an extension that implements that support.
POSIX_RLIMIT_NICEThe maximum value to which the process can be reniced to. The value that will be used will be 20 - limit, as resource limit values cannot be negative.
POSIX_RLIMIT_NOFILEA value one greater than the maximum file descriptor number that can be opened by this process.
POSIX_RLIMIT_NPROCThe maximum number of processes (and/or threads, on some operating systems) that can be created for the real user ID of the process.
POSIX_RLIMIT_RSSThe maximum size of the process's resident set, in pages.
POSIX_RLIMIT_RTPRIOThe maximum real time priority that can be set via the sched_setscheduler() and sched_setparam() system calls.
POSIX_RLIMIT_RTTIMEThe maximum amount of CPU time, in microseconds, that the process can consume without making a blocking system call if it is using real time scheduling.
POSIX_RLIMIT_SIGPENDINGThe maximum number of signals that can be queued for the real user ID of the process.
POSIX_RLIMIT_STACKThe maximum size of the process stack, in bytes.
POSIX_RLIMIT_INFINITYUsed to indicate an infinite value for a resource limit.
POSIX_RLIMIT_KQUEUESThe maximum number of kqueues this user id is allowed to create (FreeBSD).
POSIX_RLIMIT_NPTSThe maximum number of pseudo-terminals this user id is allowed to create (FreeBSD).

soft_limit

The soft limit, in whatever unit the resource limit requires, or POSIX_RLIMIT_INFINITY.

hard_limit

The hard limit, in whatever unit the resource limit requires, or POSIX_RLIMIT_INFINITY.

Return

Returns true on success or false on failure.

Examples

1 · resource soft_limit hard_limit

<?

$resource = POSIX_RLIMIT_CORE;
$soft_limit = 0;
$hard_limit = POSIX_RLIMIT_INFINITY;

$return = posix_setrlimit($resource, $soft_limit, $hard_limit);

var_export($return);
true