Search code examples
c++cmultithreadingluaobjective-c++

Stopping a runaway Lua subprocess


I have embedded Lua in an Objective-C application using LuaObjCBridge. I need to know how to stop the Lua process if it taking too much time (infinite loop?).

Would running it in a separate thread help?


Solution

  • The usual way to do this is to use lua_sethook to schedule a callback every count VM instructions; when the callback lua_Hook function occurs after a excessive time your hook function can raise an error forcing control to your protected call.