lua-users home
lua-l archive

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




The best answer appears to be to adopt what lua.c does for handling signals: Do a lua_sethook() with a low instruction count and in the hook throw an exception with luaL_error(), [1]. In my case, this code would be called by a distinct OS thread (not a signal handler), so I’m looking carefully at the thread-safety of lua_sethook().

Do you think about coroutines? The lua vm would be in a coroutine that is not the main thread. 

My solution is add some code to luaV_execute() to check a signal (A global variable) that trigger by a distinct OS thread. 

See https://github.com/cloudwu/skynet/commit/2086e13a4696792d32001f671821571fd27c6ab2#diff-77f29fbafba057306aa952d97c25d965