PHP
处理控制 | Process Control

posix_getrlimit

posix_getrlimit

(PHP 4, PHP 5, PHP 7)

posix_getrlimit — Return info about system resource limits

Description

array posix_getrlimit ( void )

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

Each resource has an associated soft and hard limit. The soft limit is the value that the kernel enforces for the corresponding resource. The hard limit acts as a ceiling for the soft limit. An unprivileged process may only set its soft limit to a value from 0 to the hard limit, and irreversibly lower its hard limit.

Return Values

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

Limit nameLimit description
coreThe 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.
totalmemThe maximum size of the memory of the process, in bytes.
virtualmemThe maximum size of the virtual memory for the process, in bytes.
dataThe maximum size of the data segment for the process, in bytes.
stackThe maximum size of the process stack, in bytes.
rssThe maximum number of virtual pages resident in RAM
maxprocThe maximum number of processes that can be created for the real user ID of the calling process.
memlockThe maximum number of bytes of memory that may be locked into RAM.
cpuThe amount of time the process is allowed to use the CPU.
filesizeThe maximum size of the data segment for the process, in bytes.
openfilesOne more than the maximum number of open file descriptors.

Examples

Example #1 Example use of posix_getrlimit()

<?php $limits = posix_getrlimit( print_r($limits ?>

The above example will output something similar to:

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 )

See Also

  • man page GETRLIMIT(2)

  • posix_setrlimit() - Set system resource limits

← posix_getpwuid

posix_getsid →

© 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

https://secure.php.net/manual/en/function.posix-getrlimit.php