|
|
1.1 root 1: .TH GETRLIMIT 2 "7 July 1983"
2: .UC 4
3: .SH NAME
4: getrlimit, setrlimit \- control maximum system resource consumption
5: .SH SYNOPSIS
6: .ft B
7: .nf
8: #include <sys/time.h>
9: #include <sys/resource.h>
10: .PP
11: .ft B
12: getrlimit(resource, rlp)
13: int resource;
14: struct rlimit *rlp;
15: .PP
16: .ft B
17: setrlimit(resource, rlp)
18: int resource;
19: struct rlimit *rlp;
20: .fi
21: .ft R
22: .SH DESCRIPTION
23: Limits on the consumption of system resources by the current process
24: and each process it creates may be obtained with the
25: .I getrlimit
26: call, and set with the
27: .I setrlimit
28: call.
29: .PP
30: The
31: .I resource
32: parameter is one of the following:
33: .TP 17
34: RLIMIT_CPU
35: the maximum amount of cpu time (in milliseconds) to be used by
36: each process.
37: .TP 17
38: RLIMIT_FSIZE
39: the largest size, in bytes, of any single file which may be created.
40: .TP 17
41: RLIMIT_DATA
42: the maximum size, in bytes, of the data segment for a process;
43: this defines how far a program may extend its break with the
44: .IR sbrk (2)
45: system call.
46: .TP 17
47: RLIMIT_STACK
48: the maximum size, in bytes, of the stack segment for a process;
49: this defines how far a program's stack segment may be extended,
50: either automatically by the system, or explicitly by a user with
51: the
52: .IR sbrk (2)
53: system call.
54: .TP 17
55: RLIMIT_CORE
56: the largest size, in bytes, of a
57: .I core
58: file which may be created.
59: .TP 17
60: RLIMIT_RSS
61: the maximum size, in bytes, a process's resident set size may
62: grow to. This imposes a limit on the amount of physical memory
63: to be given to a process; if memory is tight, the system will
64: prefer to take memory from processes which are exceeding their
65: declared resident set size.
66: .PP
67: A resource limit is specified as a soft limit and a hard limit.
68: When a soft limit is exceeded a process may receive a signal
69: (for example, if the cpu time is exceeded), but it will be allowed
70: to continue execution until it reaches the hard limit (or modifies
71: its resource limit). The
72: .I rlimit
73: structure is used to specify the hard and soft limits on a resource,
74: .PP
75: .nf
76: .RS
77: .DT
78: struct rlimit {
79: int rlim_cur; /* current (soft) limit */
80: int rlim_max; /* hard limit */
81: };
82: .RE
83: .fi
84: .PP
85: Only the super-user may raise the maximum limits. Other users
86: may only alter
87: .I rlim_cur
88: within the range from 0 to
89: .I rlim_max
90: or (irreversibly) lower
91: .IR rlim_max .
92: .PP
93: An \*(lqinfinite\*(rq value for a limit is defined as RLIMIT_INFINITY
94: (0x7\&f\&f\&f\&f\&f\&f\&f).
95: .PP
96: Because this information is stored in the per-process information,
97: this system call must be executed directly by the shell if it
98: is to affect all future processes created by the shell;
99: .I limit
100: is thus a built-in command to
101: .IR csh (1).
102: .PP
103: The system refuses to extend the data or stack space when the limits
104: would be exceeded in the normal way: a
105: .I break
106: call fails if the data space limit is reached, or the process is
107: killed when the stack limit is reached (since the stack cannot be
108: extended, there is no way to send a signal!).
109: .PP
110: A file i/o operation which would create a file which is too large
111: will cause a signal SIGXFSZ to be generated, this normally terminates
112: the process, but may be caught.
113: When the soft cpu time limit is exceeded, a signal SIGXCPU is sent to the
114: offending process.
115: .SH "RETURN VALUE
116: A 0 return value indicates that the call succeeded, changing
117: or returning the resource limit. A return value of \-1 indicates
118: that an error occurred, and an error code is stored in the global
119: location \fIerrno\fP.
120: .SH "ERRORS
121: The possible errors are:
122: .TP 15
123: [EFAULT]
124: The address specified for \fIrlp\fP is invalid.
125: .TP 15
126: [EPERM] The limit specified to \fIsetrlimit\fP would have
127: raised the maximum limit value, and the caller is not the super-user.
128: .SH SEE ALSO
129: csh(1), quota(2)
130: .SH BUGS
131: There should be
132: .I limit
133: and
134: .I unlimit
135: commands in
136: .IR sh (1)
137: as well as in
138: .IR csh.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.