posix_getrlimit

(PHP 4, PHP 5, PHP 7, PHP 8)

posix_getrlimitReturn info about system resource limits

Descrição

posix_getrlimit(?int $resource = null): array|false

posix_getrlimit() returns an array of information about the current resource's soft and hard limits.

Cada recurso tem um limite flexível e um limite rígido associado. O limite flexível é o valor que o kernel impõe ao recurso correspondente. O limite rígido funciona com um teto máximo para o limite flexível. Um processo sem privilégios pode apenas definir seu limite flexível para um valor entre 0 e o limite rígido e reduzir irreversivelmente seu limite rígido.

Parâmetros

resource

If null all resource limits will be fetched. Otherwise, the only limits of the resource type provided will be returned.

Valor Retornado

Returns an associative array of elements for each limit that is defined. Each limit has a soft and a hard limit.

List of possible limits returned
Limit name Limit description
core The maximum size of the core file. When 0, not core files are created. When core files are larger than this size, they will be truncated at this size.
totalmem The maximum size of the memory of the process, in bytes.
virtualmem The maximum size of the virtual memory for the process, in bytes.
data The maximum size of the data segment for the process, in bytes.
stack The maximum size of the process stack, in bytes.
rss The maximum number of virtual pages resident in RAM
maxproc The maximum number of processes that can be created for the real user ID of the calling process.
memlock The maximum number of bytes of memory that may be locked into RAM.
cpu The amount of time the process is allowed to use the CPU.
filesize The maximum size of the data segment for the process, in bytes.
openfiles One more than the maximum number of open file descriptors.
The function returns false on failure.

Registro de Alterações

Versão Descrição
8.3.0 The optional resource parameter has been added.

Exemplos

Exemplo #1 Example use of posix_getrlimit()

<?php

$limits
= posix_getrlimit();

print_r($limits);
?>

O exemplo acima produzirá algo semelhante a:

Array
(
    [soft core] => 0
    [hard core] => unlimited
    [soft data] => unlimited
    [hard data] => unlimited
    [soft stack] => 8388608
    [hard stack] => unlimited
    [soft totalmem] => unlimited
    [hard totalmem] => unlimited
    [soft rss] => unlimited
    [hard rss] => unlimited
    [soft maxproc] => unlimited
    [hard maxproc] => unlimited
    [soft memlock] => unlimited
    [hard memlock] => unlimited
    [soft cpu] => unlimited
    [hard cpu] => unlimited
    [soft filesize] => unlimited
    [hard filesize] => unlimited
    [soft openfiles] => 1024
    [hard openfiles] => 1024
)

Veja Também

add a note

User Contributed Notes 1 note

up
-3
petert at tebault dot org
24 years ago
The array returned (on a RH6.2 box) is:
soft core = 0
hard core = unlimited
soft data = unlimited
hard data = unlimited
soft stack = 8388608
hard stack = unlimited
soft totalmem = unlimited
hard totalmem = unlimited
soft rss = unlimited
hard rss = unlimited
soft maxproc = 2048
hard maxproc = 2048
soft memlock = unlimited
hard memlock = unlimited
soft cpu = unlimited
hard cpu = unlimited
soft filesize = unlimited
hard filesize = unlimited
soft openfiles = 1024
hard openfiles = 1024
To Top