Home

rlimit

rlimit refers to the resource limit mechanism used by POSIX-compliant operating systems to cap a process's consumption of certain resources. It is accessed through the getrlimit and setrlimit system calls and uses a structure called struct rlimit, which stores two values: rlim_cur (the soft limit) and rlim_max (the hard limit). The soft limit is the current enforcement threshold, while the hard limit acts as a ceiling that soft limits cannot exceed. The hard limit can typically be raised only by privileged processes.

Resources are identified by constants named RLIMIT_*, with common examples including RLIMIT_CPU (CPU time), RLIMIT_FSIZE (maximum

A process may lower its soft limit at any time; raising a soft limit up to the

Enforcement varies by resource and system. When a soft CPU time limit is reached, the process receives

rlimit is used for resource control, sandboxing, and system stability, enabling administrators and applications to prevent

file
size),
RLIMIT_DATA
(data
segment
size),
RLIMIT_STACK
(stack
size),
RLIMIT_CORE
(core
file
size),
RLIMIT_NOFILE
(maximum
number
of
open
file
descriptors),
and
RLIMIT_AS
(address
space).
RLIMIT_NPROC
restricts
the
number
of
processes
for
a
user.
Limits
are
inherited
by
child
processes
created
via
fork
and
persist
across
exec
unless
changed.
hard
limit
is
typically
allowed,
but
increasing
the
hard
limit
itself
generally
requires
appropriate
privileges
(such
as
root
or
capabilities
like
CAP_SYS_RESOURCE).
a
signal
(often
SIGXCPU);
depending
on
handling,
the
process
may
continue
until
the
hard
limit
is
reached,
at
which
point
it
may
be
terminated.
For
other
resources,
violations
may
result
in
signals,
errors,
or
termination,
depending
on
the
limit
type
and
kernel
behavior.
a
single
process
from
exhausting
system
resources.