[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: How can I do sethook() to all coroutines of a Lua state?
- From: Thijs Schreijer <thijs@...>
- Date: Wed, 16 Jul 2014 14:54:48 +0000
> -----Original Message-----
> From: email@example.com [mailto:firstname.lastname@example.org] On
> Behalf Of Oliver Kroth
> Sent: woensdag 16 juli 2014 14:50
> To: email@example.com
> Subject: Re: How can I do sethook() to all coroutines of a Lua state?
> 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  for some details
> 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 :-)
> 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?