Controls maximum system resource consumption.
#include <sys/time.h>
#include <sys/resource.h>
int setrlimit( Resource1, RLP)
int Resource1;
struct rlimit *RLP;
int setrlimit64 ( Resource1, RLP)
int Resource1;
struct rlimit64 *RLP;
int getrlimit ( Resource1, RLP)
int Resource1;
struct rlimit *RLP;
int getrlimit64 ( Resource1, RLP)
int Resource1;
struct rlimit64 *RLP;
vlimit ( Resource2, Value)
int Resource2, Value;
The getrlimit subroutine returns the values of limits on system resources used by the current process and its children processes. The setrlimit subroutine sets these limits. The vlimit subroutine is also supported, but the getrlimit subroutine replaces it.
A resource limit is specified as either a soft (current) or hard limit. A calling process can raise or lower its own soft limits, but it cannot raise its soft limits above its hard limits. A calling process must have root user authority to raise a hard limit.
The rlimit structure specifies the hard and soft limits for a resource, as defined in the sys/resource.h file. The RLIM_INFINITY value defines an infinite value for a limit.
When compiled in 32-bit mode, RLIM_INFINITY is a 32-bit value; when compiled in 64-bit mode, it is a 64-bit value. 32-bit routines should use RLIM64_INFINITY when setting 64-bit limits with the setrlimit64 routine, and recognize this value when returned by getrlimit64.
This information is stored as per-process information. This subroutine must be executed directly by the shell if it is to affect all future processes created by the shell.
Note: Raising the data limit does not raise the program break value. Use the brk/sbrk subroutines to raise the break value. If the proper memory segments are not initialized at program load time, raising your memory limit will not allow access to this memory. Use the -bmaxdata flag of the ld command to set up these segments at load time.
When compiled in 32-bit mode, the struct rlimit values may be returned as RLIM_SAVED_MAX or RLIM_SAVED_CUR when the actual resource limit is too large to represent as a 32-bit rlim_t.
These values can be used by library routines which set their own rlimits to save off potentially 64-bit rlimit values (and prevent them from being truncated by the 32-bit struct rlimit). Unless the library routine intends to permanently change the rlimits, the RLIM_SAVED_MAX and RLIM_SAVED_CUR values can be used to restore the 64-bit rlimits.
On successful completion, a return value of 0 is returned, changing or returning the resource limit. Otherwise, a value of -1 is returned and the errno global variable is set to indicate the error.
The getrlimit,
getrlimit64, setrlimit, setrlimit64, or
vlimit subroutine is unsuccessful if one of the following is
true:
These subroutines are part of Base Operating System (BOS) Runtime.
Application limits may be further constrained by available memory or implementation defined constants such as OPEN_MAX (maximum available open files).
The sigaction, sigvec, or signal subroutines, sigstack subroutine, ulimit subroutine.