lua-users home
lua-l archive

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


Luiz,

you are right; I want to kill the whole thing. Normally, on my system each Lua VM has its own OS process so that I do not care about parallel access (here). But the request to kill the Lua script is coming from a parallel running process, so I have to be careful.

I have now an idea how to do it safely by checking the state of the OS process that runs the Lua VM:

If the process is suspended, it is somewhere outside of the Lua VM, doing some OS stuff which blocks it from running. This is also the situation where the Lua VM would not notice the hooked function. So, I terminate the (OS) process and call lua_close() to tidy up the mess :-) To the Lua VM this might look as if the called OS function had decided to call lua_close().

If the process is running (ready to run), the Lua VM will notice the hooked function soon and suicide, so there is no need to kill it myself.

--
Oliver


Am 16.07.2014 15:56, schrieb Luiz Henrique de Figueiredo:
thank you for this pointer; this looks very deadly to the LuaState ...
My impression was that you wanted to kill the whole family.
is lua_close() signal-safe?
Probably not: lua_close probably calls the state's memory allocator to
free memory, which by default calls C's free, and also any finalizers,
which can do anything.