1GETRLIMIT(2)               Linux Programmer's Manual              GETRLIMIT(2)
2
3
4

NAME

6       getrlimit, setrlimit, prlimit - get/set resource limits
7

SYNOPSIS

9       #include <sys/resource.h>
10
11       int getrlimit(int resource, struct rlimit *rlim);
12       int setrlimit(int resource, const struct rlimit *rlim);
13
14       int prlimit(pid_t pid, int resource, const struct rlimit *new_limit,
15                   struct rlimit *old_limit);
16
17   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
18
19       prlimit():
20           _GNU_SOURCE
21

DESCRIPTION

23       The  getrlimit() and setrlimit() system calls get and set resource lim‐
24       its.  Each resource has an associated soft and hard limit,  as  defined
25       by the rlimit structure:
26
27           struct rlimit {
28               rlim_t rlim_cur;  /* Soft limit */
29               rlim_t rlim_max;  /* Hard limit (ceiling for rlim_cur) */
30           };
31
32       The  soft  limit  is  the value that the kernel enforces for the corre‐
33       sponding resource.  The hard limit acts  as  a  ceiling  for  the  soft
34       limit:  an  unprivileged process may set only its soft limit to a value
35       in the range from 0 up to the hard limit, and (irreversibly) lower  its
36       hard   limit.    A  privileged  process  (under  Linux:  one  with  the
37       CAP_SYS_RESOURCE capability in the initial user namespace) may make ar‐
38       bitrary changes to either limit value.
39
40       The  value  RLIM_INFINITY  denotes  no limit on a resource (both in the
41       structure returned by getrlimit() and in the structure passed to  setr‐
42       limit()).
43
44       The resource argument must be one of:
45
46       RLIMIT_AS
47              This  is  the  maximum size of the process's virtual memory (ad‐
48              dress space).  The limit is specified in bytes, and  is  rounded
49              down  to  the  system  page  size.   This limit affects calls to
50              brk(2), mmap(2), and mremap(2), which fail with the error ENOMEM
51              upon  exceeding this limit.  In addition, automatic stack expan‐
52              sion fails (and generates a SIGSEGV that kills the process if no
53              alternate  stack  has  been  made available via sigaltstack(2)).
54              Since the value is a long, on machines with a 32-bit long either
55              this limit is at most 2 GiB, or this resource is unlimited.
56
57       RLIMIT_CORE
58              This  is  the maximum size of a core file (see core(5)) in bytes
59              that the process may dump.  When 0 no core dump files  are  cre‐
60              ated.  When nonzero, larger dumps are truncated to this size.
61
62       RLIMIT_CPU
63              This  is a limit, in seconds, on the amount of CPU time that the
64              process can consume.  When the process reaches the  soft  limit,
65              it is sent a SIGXCPU signal.  The default action for this