summaryrefslogtreecommitdiff
path: root/lib/supple/host.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lib/supple/host.lua')
-rw-r--r--lib/supple/host.lua18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/supple/host.lua b/lib/supple/host.lua
index f0181fa..bac95ae 100644
--- a/lib/supple/host.lua
+++ b/lib/supple/host.lua
@@ -17,6 +17,7 @@ local objects = require 'supple.objects'
local hostname = "host"
local counter = 0
+local limits
local function run_wrapper()
local wrapperpath = "@@WRAPPER_BIN@@"
@@ -63,12 +64,22 @@ local function run_sandbox(codestr, codename, ...)
-- which we do not need to fill out.
err = nil
+ local limitsok, limitserr = true
+ if limits then
+ limitsok, limitserr = comms.call("supple:set_limits", "__call", limits)
+ end
+
-- In a protected manner, capture the output of the call
local args, ret = {...}
local function capture()
ret = {func(unpack(args))}
end
- local ok, err = pcall(capture)
+ local ok
+ if limitsok then
+ ok, err = pcall(capture)
+ else
+ ok, err = limitsok, limitserr
+ end
-- We need to clean up, so dump all the objects
func = nil
-- And ask the supple API to clear down too
@@ -89,7 +100,12 @@ local function set_hostname(newname)
counter = 0
end
+local function set_limits(newlimits)
+ limits = newlimits
+end
+
return {
run = run_sandbox,
set_name = set_hostname,
+ set_limits = set_limits,
} \ No newline at end of file