lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



I want to limit the scripts to execute only for a specified period of time. I.e. if the script executes for more than a second, lua should terminate it

Set hooks and test for the time inside the hook. Raise an error if the time is up. If you're running Unix, you can set an alarm and insidethe alarm handler set a hook to terminate the Lua run.See lua.c and my lalarm.

Actually what I'm trying to achieve is protection from code like

  while true do end

I checked the manual and I think that should use
lua_sethook(*,my_hook,LUA_MASKCOUNT,1000)
where my_hook should call lua_error to stop the script.
Is this what you suggested?
And finally, where I can get your lalarm from?
Thanks again,
Todor