lua-users home
lua-l archive

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


With the interesting thread going by with lua_sethook(), that reminds me of something I have currently waiting to be implemented on my current (and first) lua project --- stopping runaway execution. Infinite loops and such.

I'm in a multithreaded environment, with a separate lua state for each thread - no sharing.
Unfortunately, i'm embedding in a larger application that i have no control over.

Most of the suggestions about killing lua execution seem to revolve around starting a thread, executing lua in that, and terminating the thread if something bad is detected. Are there any other options for stopping the execution of a lua_pcall() from the outside?

For infinite loops, using lua_sethook() with a high count is sufficient for me -- it doesn't matter if it takes a while. But once in the hook function, is there some way to tell lua "when i return, you should stop execution and return from the lua_pcall() that started all this".

I haven't tried, but first thing that comes to mind is to inject an error when inside the hook function, but thats an ugly solution.

Hope this makes sense.
cheers -- j