lua-users home
lua-l archive

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


>>>>> "AG" == Alexander Gladysh <agladysh@gmail.com> writes:

 >>> 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...

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

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

another intresting question is how much will it affect the performance?

-- 
Yours sincerely, Eugeny.
Doctor Web, Ltd. http://www.drweb.com
+79119997425