xref: /386bsd/usr/share/man/cat2/getrlimit.0 (revision a2142627)
1GETRLIMIT(2)              386BSD Programmer's Manual              GETRLIMIT(2)
2
3NNAAMMEE
4     ggeettrrlliimmiitt, sseettrrlliimmiitt - control maximum system resource consumption
5
6SSYYNNOOPPSSIISS
7     ##iinncclluuddee <<ssyyss//ttiimmee..hh>>
8     ##iinncclluuddee <<ssyyss//rreessoouurrccee..hh>>
9
10     _i_n_t
11     ggeettrrlliimmiitt(_i_n_t _r_e_s_o_u_r_c_e, _s_t_r_u_c_t _r_l_i_m_i_t *_r_l_p)
12
13     _i_n_t
14     sseettrrlliimmiitt(_i_n_t _r_e_s_o_u_r_c_e, _s_t_r_u_c_t _r_l_i_m_i_t *_r_l_p)
15
16DDEESSCCRRIIPPTTIIOONN
17     Limits on the consumption of system resources by the current process and
18     each process it creates may be obtained with the ggeettrrlliimmiitt() call, and
19     set with the sseettrrlliimmiitt() call.
20
21     The _r_e_s_o_u_r_c_e parameter is one of the following:
22
23     RLIMIT_CPU      the maximum amount of cpu time (in seconds) to be used by
24                     each process.
25
26     RLIMIT_FSIZE    the largest size, in bytes, of any single file that may
27                     be created.
28
29     RLIMIT_DATA     the maximum size, in bytes, of the data segment for a
30                     process; this defines how far a program may extend its
31                     break with the sbrk(2) system call.
32
33     RLIMIT_STACK    the maximum size, in bytes, of the stack segment for a
34                     process; this defines how far a program's stack segment
35                     may be extended.  Stack extension is performed
36                     automatically by the system.
37
38     RLIMIT_CORE     the largest size, in bytes, of a core file that may be
39                     created.
40
41     RLIMIT_RSS      the maximum size, in bytes, to which a process's resident
42                     set size may grow.  This imposes a limit on the amount of
43                     physical memory to be given to a process; if memory is
44                     tight, the system will prefer to take memory from
45                     processes that are exceeding their declared resident set
46                     size.
47
48     RLIMIT_MEMLOCK  the maximum size, in bytes, of locked down (e.g. forced
49                     resident) memory that can be used by a process. By
50                     definition, one cannot lock more memory than is resident,
51                     more memory than is allocated to a process, or more
52                     memory than is present for use by processes within the
53                     computer.  N.B. memory involved in read/write operations
54                     is also temporarily locked resident; these operations do
55                     not affect this resource in any way.
56
57     RLIMIT_NPROC    the maximum number of processes per user
58
59     A resource limit is specified as a soft limit and a hard limit.  When a
60     soft limit is exceeded a process may receive a signal (for example, if
61     the cpu time or file size is exceeded), but it will be allowed to
62     continue execution until it reaches the hard limit (or modifies its
63     resource limit).  The _r_l_i_m_i_t structure is used to specify the hard and
64     soft limits on a resource,
65
66           struct rlimit {
67                   int     rlim_cur;       /* current (soft) limit */
68                   int     rlim_max;       /* hard limit */
69           };
70
71     Only the super-user may raise the maximum limits.  Other users may only
72     alter _r_l_i_m__c_u_r within the range from 0 to _r_l_i_m__m_a_x or (irreversibly)
73     lower _r_l_i_m__m_a_x.
74
75     An ``infinite'' value for a limit is defined as RLIM_INFINITY
76     (0x7fffffff).
77
78     Because this information is stored in the per-process information, this
79     system call must be executed directly by the shell if it is to affect all
80     future processes created by the shell; lliimmiitt is thus a built-in command
81     to csh(1).
82
83     The system refuses to extend the data or stack space when the limits
84     would be exceeded in the normal way: a break call fails if the data space
85     limit is reached.  When the stack limit is reached, the process receives
86     a segmentation fault (SIGSEGV); if this signal is not caught by a handler
87     using the signal stack, this signal will kill the process.
88
89     A file I/O operation that would create a file larger that the process'
90     soft limit will cause the write to fail and a signal SIGXFSZ to be
91     generated; this normally terminates the process, but may be caught.  When
92     the soft cpu time limit is exceeded, a signal SIGXCPU is sent to the
93     offending process.
94
95RREETTUURRNN VVAALLUUEESS
96     A 0 return value indicates that the call succeeded, changing or returning
97     the resource limit.   A return value of -1 indicates that an error
98     occurred, and an error code is stored in the global location _e_r_r_n_o.
99
100EERRRROORRSS
101     GGeettrrlliimmiitt() and sseettrrlliimmiitt() will fail if:
102
103     [EFAULT]      The address specified for _r_l_p is invalid.
104
105     [EPERM]       The limit specified to sseettrrlliimmiitt() would have raised the
106                   maximum limit value, and the caller is not the super-user.
107
108SSEEEE AALLSSOO
109     csh(1),  quota(2),  sigvec(2),  sigstack(2)
110
111BBUUGGSS
112     There should be lliimmiitt and uunnlliimmiitt commands in sh(1) as well as in csh.
113
114HHIISSTTOORRYY
115     The ggeettrrlliimmiitt function call appeared in 4.2BSD.
116
1174th Berkeley Distribution       March 10, 1991                               2
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133