Flowdock
setrlimit(*args) 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. It should be a symbol such as :CORE, a string such as “CORE” or a constant such as Process::RLIMIT_CORE. The available resources are OS dependent. Ruby may support following resources.

AS

total available memory (bytes) (SUSv3, NetBSD, FreeBSD, OpenBSD but 4.4BSD-Lite)

CORE

core size (bytes) (SUSv3)

CPU

CPU time (seconds) (SUSv3)

DATA

data segment (bytes) (SUSv3)

FSIZE

file size (bytes) (SUSv3)

MEMLOCK

total size for mlock(2) (bytes) (4.4BSD, GNU/Linux)

MSGQUEUE

allocation for POSIX message queues (bytes) (GNU/Linux)

NICE

ceiling on process’s nice(2) value (number) (GNU/Linux)

NOFILE

file descriptors (number) (SUSv3)

NPROC

number of processes for the user (number) (4.4BSD, GNU/Linux)

RSS

resident memory size (bytes) (4.2BSD, GNU/Linux)

RTPRIO

ceiling on the process’s real-time priority (number) (GNU/Linux)

RTTIME

CPU time for real-time process (us) (GNU/Linux)

SBSIZE

all socket buffers (bytes) (NetBSD, FreeBSD)

SIGPENDING

number of queued signals allowed (signals) (GNU/Linux)

STACK

stack size (bytes) (SUSv3)

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

The following example raises the soft limit of core size to the hard limit to try to make core dump possible.

Process.setrlimit(:CORE, Process.getrlimit(:CORE)[1])
Show source
Register or log in to add new notes.