Module posix.sys.resource
Control Maximum System Resource Consumption.
-
getrlimit (resource)
-
Get resource limits for this process.
Parameters:
- resource
int
one of
RLIMIT_CORE
, RLIMIT_CPU
, RLIMIT_DATA
, RLIMIT_FSIZE
,
RLIMIT_NOFILE
, RLIMIT_STACK
or RLIMIT_AS
Returns:
-
int
softlimit
-
int
hardlimit, if successful
Or
-
nil
-
string
error message
-
int
errnum
See also:
Usage:
local sysres = require "posix.sys.resource"
sysres.getrlimit(sysres.RLIMIT_NOFILE)
-
setrlimit (resource[, softlimit[, hardlimit]])
-
Set a resource limit for subsequent child processes.
Parameters:
- resource
int
one of
RLIMIT_CORE
, RLIMIT_CPU
, RLIMIT_DATA
, RLIMIT_FSIZE
,
RLIMIT_NOFILE
, RLIMIT_STACK
or RLIMIT_AS
- softlimit
process may receive a signal when reached
(optional)
- hardlimit
process may be terminated when reached
(optional)
Returns:
int
0
, if successful
Or
-
nil
-
string
error message
-
int
errnum
See also:
Usage:
local sysres = require "posix.sys.resource"
local lim = sysres.getlimit(sysres.RLIMIT_NOFILE)
lim.rlim_cur = lim.rlim_cur / 2
sysres.setrlimit(sysres.RLIMIT_NOFILE, lim)
-
PosixRlimit
-
Resource limit record.
Fields:
- rlim_cur
int
current soft limit
- rlim_max
int
hard limit
-
posix.sys.resource
-
Rlimit constants.
Fields:
- RLIM_INFINITY
int
unlimited resource usage
- RLIM_SAVED_CUR
int
saved current resource soft limit
- RLIM_SAVED_MAX
int
saved resource hard limit
- RLIMIT_CORE
int
maximum bytes allowed for a core file
- RLIMIT_CPU
int
maximum cputime secconds allowed per process
- RLIMIT_DATA
int
maximum data segment bytes per process
- RLIMIT_FSIZE
int
maximum bytes in any file
- RLIMIT_NOFILE
int
maximum number of open files per process
- RLIMIT_STACK
int
maximum stack segment bytes per process
- RLIMIT_AS
int
maximum bytes total address space per process
Usage:
for name, value in pairs (require "posix.sys.resource") do
if type (value) == "number" then
print (name, value)
end
end