lua-users home
lua-l archive

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



> -----Original Message-----
> From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On
> Behalf Of Oliver Kroth
> Sent: woensdag 16 juli 2014 14:50
> To: lua-l@lists.lua.org
> Subject: Re: How can I do sethook() to all coroutines of a Lua state?
> 
> Thijs,
> 
> nothing very special, I just wanted to terminate a running script from
> another OS process.
> lua.c uses for this the function Lua_sethook() and inserts a C function
> that throws an "stopped" error..

Does it also work when it is inside a pcall()? Throwing errors to kill a coroutine works, but only if it is not protected.

See corowatch [1] for some details

Thijs

[1] https://github.com/Tieske/corowatch/blob/master/README.md#limitations 


> 
> Works like a charm, but if you attach your stopper into the hook of a
> thread (coroutine) that is not the main thread, only this thread is
> stopped; the others, including the main thread, survive.
> 
> Luckily, finding the main thread is relatively easy:
> go from LuaState *L to the global state and from there to its main
> thread: G(L)->mainthread
> Then, shoot the boss :-)
> 
> --
> Oliver
> 
> 16.07.2014 14:33, Thijs Schreijer wrote:
> >
> > It will work for all operations, not just debug. But monkey patching is
> considered harmful around here. But if it works for you, nobody is stopping
> you from doing so. What do you want to accomplish with the debughooks?
> >
> >
>