Manual Page Result
0
Command: setrlimit | Section: 2 | Source: Digital UNIX | File: setrlimit.2.gz
getrlimit(2) System Calls Manual getrlimit(2)
NAME
getrlimit, setrlimit - Controls maximum system resource consumption
SYNOPSIS
#include <sys/resource.h>
int getrlimit(
int resource1,
struct rlimit *rlp);
int setrlimit(
int resource1,
const struct rlimit *rlp);
[Digital] The following declaration of the setrlimit() function does
not conform to current standards and is supported only for backward
compatibility:
int setrlimit(
int resource1,
struct rlimit *rlp);
[Digital] Application developers may want to specify an #include
statement for <sys/time.h> before the one for <sys/resource.h> if pro-
grams are being developed for multiple platforms. The additional #in-
clude statement is not required on DIGITAL UNIX systems or by ISO or
X/Open standards, but may be required on other vendors' systems that
conform to these standards.
STANDARDS
Interfaces documented on this reference page conform to industry stan-
dards as follows:
getrlimit(), setrlimit(): XPG4-UNIX
Refer to the standards(5) reference page for more information about in-
dustry standards and associated tags.
PARAMETERS
Specifies one of the following values: The maximum size, in bytes, of
the total memory available to a process. Exceeding this limit causes
the brk(), malloc(), mmap(), and sbrk() functions to fail with errno
set to [ENOMEM]. Also, the automatic stack growth will fail with the
effects described under RLIMIT_STACK. The largest size, in bytes, of a
core file that can be created. A limit of 0 (zero) prevents the process
from creating a core file. If a process exceeds this limit, any remain-
ing data to be written to the core file is lost. The maximum amount of
CPU time (in seconds) to be used by a process. If the process exceeds
this limit, the system sends the SIGXCPU signal to the process. The
maximum size, in bytes, of a process's data segment. Exceeding this
limit causes the brk(), malloc(), mmap(), and sbrk() functions to fail
with errno set to [ENOMEM]. The maximum size, in bytes, of any single
file that can be created. A limit of 0 (zero) prevents the process from
creating a file. If a write or truncate operation would cause this
limit to be exceeded, the system generates the SIGXFSZ signal. If the
process is blocking, catching, or ignoring SIGXFSZ, continued attempts
to increase the size of a file from end-of-file to beyond the limit
will fail with errno set to [EFBIG]. The maximum number of open file
descriptors that the process can have. Any functions that attempt to
create new file descriptors when the maximum hard limit has been
reached will fail with errno set to [EMFILE].
[Digital] The default maximum is 4096 file descriptors. The
maximum can be 64K file descriptors when a process has enabled
support for greater than 4096 open file descriptors. [Digi-
tal] The maximum size, in bytes, to which a process's resident
set size can grow. This value imposes a limit on the amount of
physical memory to be given to a process. If memory is in short
supply, the system prefers to take memory from processes that
are exceeding their declared resident set size. The maximum
size, in bytes, of a process's stack. The system will not auto-
matically grow the stack beyond this limit. If this limit is
exceeded, SIGSEGV is generated for the process. If the process
is blocking or ignoring SIGSEGV, or is catching SIGSEGV and has
not made arrangements to use an alternate stack, the disposition
of SIGSEGV is set to SIG_DFL before it is generated. Points to
the rlimit structure, which contains the current soft and hard
limits. For the getrlimit() function, the requested limits are
returned in this structure; for the setrlimit() function, the
desired new limits are specified here.
DESCRIPTION
The getrlimit() function obtains the limits on the consumption of sys-
tem resources by the current process and each process it creates. You
use the setrlimit() function to set these resources.
Each resource limit is specified as either a soft limit or a hard
limit. When a soft limit is exceeded (for example, if the CPU time is
exceeded), a process can receive a signal until it reaches the hard
limit or until it modifies its resource limit. The rlimit structure is
used to specify the hard and soft limits on a resource, as defined in
the sys/resource.h header file.
The calling process must have superuser privilege in order to raise the
maximum limits. An unprivileged process can alter the rlim_cur field
of the rlimit structure within the range from 0 (zero) to rlim_max or
can (irreversibly) lower rlim_max.
An infinite value for a limit is defined as RLIM_INFINITY.
Because this information is stored in the per-process information, and
inherited by fork(), the setrlimit() function should be executed di-
rectly by the shell in order to affect all future processes created by
the shell. Thus, limit is a built-in command to the shells.
NOTES
The ulimit() function is implemented in terms of setrlimit(). There-
fore, the two interfaces should not be used in the same program. The
result of doing so is undefined.
[Digital] When compiled in the X/Open UNIX environment, calls to the
setrlimit() function are internally renamed by prepending _E to the
function name. When you are debugging a module that includes the setr-
limit() function and for which _XOPEN_SOURCE_EXTENDED has been defined,
use _Esetrlimit to refer to the setrlimit() call. See standards(5) for
further information.
RETURN VALUES
Upon successful completion, these functions return a value of 0 (zero).
Otherwise, the functions return a value of -1 and set errno to indicate
the error.
ERRORS
If the getrlimit() or setrlimit() function fails, errno might be set to
one of the following values: [Digital] The address specified for the
rlp parameter is invalid. An invalid resource was specified, or the
new rlim_cur specified in a setrlimit() call exceeds the new rlim_max
specified in that same call. The limit specified to the setrlimit()
function would have raised the maximum limit value, and the calling
process does not have appropriate privilege.
RELATED INFORMATION
Functions: quotactl(2), setsysinfo(2), sigaction(2), sigstack(2),
sigvec(2)
Routines: ulimit(3)
Standards: standards(5) delim off
getrlimit(2)