setrlimit(...) public

Sets the resource limit of the process. cur_limit means current (soft) limit and max_limit means maximum (hard) limit.

If max_limit is not given, cur_limit is used.

resource indicates the kind of resource to limit. The list of resources are OS dependent. Ruby may support following resources.

Process::RLIMIT_CORE
core size (bytes) (SUSv3)
Process::RLIMIT_CPU
CPU time (seconds) (SUSv3)
Process::RLIMIT_DATA
data segment (bytes) (SUSv3)
Process::RLIMIT_FSIZE
file size (bytes) (SUSv3)
Process::RLIMIT_NOFILE
file descriptors (number) (SUSv3)
Process::RLIMIT_STACK
stack size (bytes) (SUSv3)
Process::RLIMIT_AS
total available memory (bytes) (SUSv3, NetBSD, FreeBSD, OpenBSD but 4.4BSD-Lite)
Process::RLIMIT_MEMLOCK
total size for mlock(2) (bytes) (4.4BSD, GNU/Linux)
Process::RLIMIT_NPROC
number of processes for the user (number) (4.4BSD, GNU/Linux)
Process::RLIMIT_RSS
resident memory size (bytes) (4.2BSD, GNU/Linux)
Process::RLIMIT_SBSIZE
all socket buffers (bytes) (NetBSD, FreeBSD)

Other Process::RLIMIT_??? constants may be defined.

cur_limit and max_limit may be Process::RLIM_INFINITY, which means that the resource is not limited. They may be Process::RLIM_SAVED_MAX or Process::RLIM_SAVED_CUR too. See system setrlimit(2) manual for details.

Show source
Register or log in to add new notes.