The setrlimit callable service sets resource limits for the calling process. A resource limit is a pair of values; one specifies the current (soft) limit and the other the maximum (hard) limit.
Operation | Environment |
---|---|
Authorization: | Supervisor or problem state, any PSW key |
Dispatchable unit mode: | Task |
Cross memory mode: | PASN = HASN |
AMODE (BPX1SRL): | 31-bit |
AMODE (BPX4SRL): | 64-bit |
ASC mode: | Primary mode |
Interrupt status: | Enabled for interrupts |
Locks: | Unlocked |
Control parameters: | All parameters must be addressable by the caller and in the primary address space. |
|
AMODE 64 callers use BPX4SRL with the same parameters.
Resource | Description | Action when soft limit is exceeded |
---|---|---|
RLIMIT_MEMLIMIT | Maximum amount of usable storage above the bar (in 1-MB segments) that can be allocated at one time. | Any attempt to allocate or extend the usable amount of virtual storage above the 2-MB addressing range fails. |
RLIMIT_CORE | Maximum core file size (in bytes) created by a process. A value of 0 prevents core file creation. | Core file writing terminates at this size. |
RLIMIT_CPU | Maximum amount of CPU time (in seconds) used by a process. | SIGXCPU is sent to the process, and the process is granted a small extension to allow for signal generation and delivery. If the extension is used up, the process is terminated with a SIGKILL. |
RLIMIT_FSIZE | Maximum file size (in bytes) created by a process. A value of 0 prevents the creation of new files and the expansion of existing files. | SIGXFSZ is sent to the process. If the process is blocking, catching, or ignoring SIGXFSZ, continued attempts to increase the size of a file beyond the limit fail with a return code of EFBIG. |
RLIMIT_NOFILE | Maximum number of open file descriptors for a process. This number is one greater than the maximum value that may be assigned to a newly-created descriptor. | Functions that create new file descriptors after the limit is reached fail with a return code of EMFILE. |
RLIMIT_AS | Maximum address space size (in bytes) for a process. | The mmap and shmat callable services fail with a return code of ENOMEM. User getmain and storage obtain requests fail (for example, runtime library stack and heap expansion fails). |
The RLIMIT_ constants are defined in the BPXYCONS macro. See BPXYCONS — Constants used by services.
The name of an Rlimit structure that contains the values for the hard (maximum) and soft (current) limits for the resource that is identified by the resource parameter. Macro BPXYRLIM defines the Rlimit structure. (See BPXYRLIM — Map the rlimit, rusage, and timeval structures.) Each limit value contains two fullwords. For all resources except RLIMIT_FSIZE, the upper fullword for each limit value is ignored.
The name of a fullword in which the setrlimit service returns a value of zero if it is successful, and -1 if it is not successful.
Return_code | Explanation |
---|---|
EINVAL | The operation is not permitted for one of the following reasons:
|
EMVSSAF2ERR | A Security product internal error has occurred. Consult the Reason_code parameter for the exact reason for the error. |
EPERM | An attempt was made to raise a hard (maximum) limit, but the calling process did not have superuser authority. The following reason code can accompany the return code: JrRaiseHardLimit. |
The name of a fullword in which the setrlimit service stores the reason code. The setrlimit service returns Reason_code only if Return_value is -1. Reason_code further qualifies the Return_code value. For the reason codes, see z/OS UNIX System Services Messages and Codes.
An exception to this rule occurs when the process is running in an address space that contains multiple processes. When you change the RLIMIT_CPU, you can set a new soft limit that is greater than the time limit of the current process, yet greater than the time consumed by the address space. This allows the setrlimit call to succeed, and a SIGXCPU signal is generated. The alternative is not to run multiple processes in the same address space.
None.
For an example using this callable service, see BPX1SRL (setrlimit) example.