lua-users home
lua-l archive

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


Thijs,

thank you for your valuable information. I managed now to kill the main thread by hooking into G(L)->mainthread, and the current thread (if different) a function that inserts itself again, and errors:

void fullstop( lua_State *L, lua_Debug *ar )
{
    (void)ar;  /* unused arg. */
lua_sethook( L, fullstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1 );
    luaL_error( L, "stopped");
}

...

lua_sethook( mainthread, fullstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1 );
if (mainthread != L)
lua_sethook( L, fullstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1 );

--
Oliver


Am 16.07.2014 16:54, schrieb Thijs Schreijer:

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