1GETRLIMIT(2)                  System Calls Manual                 GETRLIMIT(2)
2
3
4

NAME

6       getrlimit, setrlimit - control maximum system resource consumption
7

SYNOPSIS

9       #include <sys/time.h>
10       #include <sys/resource.h>
11
12       getrlimit(resource, rlp)
13       int resource;
14       struct rlimit *rlp;
15
16       setrlimit(resource, rlp)
17       int resource;
18       struct rlimit *rlp;
19

DESCRIPTION

21       Limits  on  the  consumption of system resources by the current process
22       and each process it creates may be obtained with  the  getrlimit  call,
23       and set with the setrlimit call.
24
25       The resource parameter is one of the following:
26
27       RLIMIT_CPU       the maximum amount of cpu time (in seconds) to be used
28                        by each process.
29
30       RLIMIT_FSIZE     the largest size, in bytes, of any  single  file  that
31                        may be created.
32
33       RLIMIT_DATA      the  maximum size, in bytes, of the data segment for a
34                        process; this defines how far a program may extend its
35                        break with the sbrk(2) system call.
36
37       RLIMIT_STACK     the maximum size, in bytes, of the stack segment for a
38                        process; this defines how far a program's  stack  seg‐
39                        ment  may  be  extended.  Stack extension is performed
40                        automatically by the system.
41
42       RLIMIT_CORE      the largest size, in bytes, of a core file that may be
43                        created.
44
45       RLIMIT_RSS       the maximum size, in bytes, to which a process's resi‐
46                        dent set size may grow.  This imposes a limit  on  the
47                        amount of physical memory to be given to a process; if
48                        memory is tight, the system will prefer to take memory
49                        from processes that are exceeding their declared resi‐
50                        dent set size.
51
52       A resource limit is specified as a soft limit and a hard limit.  When a
53       soft  limit is exceeded a process may receive a signal (for example, if
54       the cpu time is exceeded), but it will be allowed to continue execution
55       until  it reaches the hard limit (or modifies its resource limit).  The
56       rlimit structure is used to specify the  hard  and  soft  limits  on  a
57       resource,
58
59              struct rlimit {
60                   int  rlim_cur; /* current (soft) limit */
61                   int  rlim_max; /* hard limit */
62              };
63
64       Only the super-user may raise the maximum limits.  Other users may only
65       alter rlim_cur within the range from 0 to  rlim_max  or  (irreversibly)
66       lower rlim_max.
67
68       An   “infinite”   value   for  a  limit  is  defined  as  RLIM_INFINITY
69       (0x7fffffff).
70
71       Because this information is stored in the per-process information, this
72       system  call  must be executed directly by the shell if it is to affect
73       all future processes created by the shell; limit  is  thus  a  built-in
74       command to csh(1).
75
76       The  system  refuses  to extend the data or stack space when the limits
77       would be exceeded in the normal way: a break call  fails  if  the  data
78       space  limit  is reached.  When the stack limit is reached, the process
79       receives a segmentation fault (SIGSEGV); if this signal is  not  caught
80       by a handler using the signal stack, this signal will kill the process.
81
82       A  file  I/O  operation that would create a file that is too large will
83       cause a signal SIGXFSZ to be generated; this  normally  terminates  the
84       process,  but may be caught.  When the soft cpu time limit is exceeded,
85       a signal SIGXCPU is sent to the offending process.
86

RETURN VALUE

88       A 0 return value indicates that the call succeeded, changing or return‐
89       ing  the resource limit.   A return value of -1 indicates that an error
90       occurred, and an error code is stored in the global location errno.
91

ERRORS

93       The possible errors are:
94
95       [EFAULT]       The address specified for rlp is invalid.
96
97       [EPERM]   The limit specified to setrlimit would have
98                      raised the maximum limit value, and the  caller  is  not
99                      the super-user.
100

SEE ALSO

102       csh(1), quota(2), sigvec(2), sigstack(2)
103

BUGS

105       There should be limit and unlimit commands in sh(1) as well as in csh.
106
107
108
1094th Berkeley Distribution        May 13, 1986                     GETRLIMIT(2)
Impressum