You can specify limits for the resource usage of a process. When the process tries to exceed a limit, it may get a signal, or the system call by which it tried to do so may fail, depending on the limit. Each process initially inherits its limit values from its parent, but it can subsequently change them.
The symbols in this section are defined in `sys/resource.h'.
*rlp
.
The return value is 0
on success and -1
on failure. The
only possible errno
error condition is EFAULT
.
When the sources are compiled with _FILE_OFFSET_BITS == 64
on a
32 bits system this function is in fact getrlimit64
. I.e., the
LFS interface transparently replaces the old interface.
getrlimit
but its second
parameter is a pointer to a variable of type struct rlimit64
which allows this function to read values which wouldn't fit in the
member of a struct rlimit
.
If the sources are compiled with _FILE_OFFSET_BITS == 64
on a 32
bits machine this function is available under the name getrlimit
and so transparently replaces the old interface.
*rlp
.
The return value is 0
on success and -1
on failure. The
following errno
error condition is possible:
EPERM
When the sources are compiled with _FILE_OFFSET_BITS == 64
on a
32 bits system this function is in fact setrlimit64
. I.e., the
LFS interface transparently replaces the old interface.
setrlimit
but its second
parameter is a pointer to a variable of type struct rlimit64
which allows this function to set values which wouldn't fit in the
member of a struct rlimit
.
If the sources are compiled with _FILE_OFFSET_BITS == 64
on a 32
bits machine this function is available under the name setrlimit
and so transparently replaces the old interface.
getrlimit
to receive limit values,
and with setrlimit
to specify limit values. It has two fields:
rlim_t rlim_cur
rlim_t rlim_max
In getrlimit
, the structure is an output; it receives the current
values. In setrlimit
, it specifies the new values.
For the LFS functions a similar type is defined in `sys/resource.h'.
getrlimit64
to receive limit values,
and with setrlimit64
to specify limit values. It has two fields:
rlim64_t rlim_cur
rlim64_t rlim_max
In getrlimit64
, the structure is an output; it receives the current
values. In setrlimit64
, it specifies the new values.
Here is a list of resources that you can specify a limit for. Those that are sizes are measured in bytes.
RLIMIT_CPU
SIGXCPU
. The value is
measured in seconds. See section Operation Error Signals.
RLIMIT_FSIZE
SIGXFSZ
. See section Operation Error Signals.
RLIMIT_DATA
RLIMIT_STACK
SIGSEGV
signal.
See section Program Error Signals.
RLIMIT_CORE
RLIMIT_RSS
RLIMIT_MEMLOCK
RLIMIT_NPROC
fork
will fail
with EAGAIN
. See section Creating a Process.
RLIMIT_NOFILE
RLIMIT_OFILE
EMFILE
.
See section Error Codes. Not all systems support this limit; GNU does, and
4.4 BSD does.
RLIM_NLIMITS
RLIM_NLIMITS
.
setrlimit
.
Two historical functions for setting resource limits, ulimit
and
vlimit
, are not documented here. The latter is declared in
`sys/vlimit.h' and comes from BSD.
Go to the first, previous, next, last section, table of contents.