lua-users home
lua-l archive

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

On Tue, Feb 24, 2009 at 6:08 PM, Jeff Pohlmeyer
<> wrote:
> On Tue, Feb 24, 2009 at 7:04 AM, Alexander Gladysh <> wrote:

>> Say, I set instruction count hook. If it is triggered (and some
>> condition is met -- given time passed, for example), I need to kill
>> Lua state. How do I kill it most gracefully? I'd like all allocated
>> resources to be freed. (I think it would be perfect to be able to
>> imitate conventional runtime error raised from the hook point. Not
>> sure if this is achievable though...)

> I have an application that does this,
> from inside the debug hook callback:

> if (timeout) {
>  lua_pushstring(L, "Script timeout.");
>  lua_error(L);
> }

> and it *seems* to work fine, but I'm no expert...

I see this is a popular solution. Thank you everyone who answered my question!

Can any Lua internals expert confirm that this is safe? Can
instruction count debug hook get called in the middle of something

I would settle for positive answer covering "current implementation",
but it would be great to have a legal  way to terminate Lua state (or
trigger Lua error) from the hook.