Resource limits

You can also use the resource module to get and set resource limits. Each controllable resource has a soft limit and a hard limit. When a process's resource usage crosses a soft limit, it receives a signal indicating that it has crossed that boundary. A process can never exceed a hard limit, however. Attempting to do so usually results in the termination of the process.

Note Only superusers can alter the hard limits.

The getrlimit(resource) function returns a tuple (soft, hard) containing the limit values for that resource. setrlimit(resource, (soft, hard)) sets new limits for resource (you can use limit values of -1 to specify the maximum allowable value). Table 38-8 lists the resource names and their meanings (sizes are in bytes); if a particular platform does not support a resource then it will not be in the resource module.

Table 38-8 Resource Names and Meanings

Name

0 0

Post a comment