> Depending on what you do next with the Lua state,
...
lua_close
> ... you may not have to terminate each separate thread.
I found out, if I only add hooks to the mainstate and the calling thread state (G(L)->mainthread and L), an intermediate coroutine may still be running:
In the situation "maintread --> start coroutine1 --> start coroutine2 --> my_exit", I have to add hooks to all three coroutines, otherwise coroutine1 will keep running.
(I investigated this with some test code, but that's rather lengthy).
It might not be necessary to add a hook to all Lua coroutines, but only the ones that are involved in the call to "my_exit". But for this I would need an API function like
lua_State * lua_getparentthread(lua_State *L) to recursively determine all involved thread states - but there is no such API function (or: I am unable to find it).
I could store the required information on my own - again using
luai_userstatethread - but does it really harm to hook other thread states in the same main state?