luaa: restart awesome on Lua PANIC

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-08-27 16:04:40 +02:00
parent d126b554db
commit 0b3b13ba19
1 changed files with 12 additions and 0 deletions

12
luaa.c
View File

@ -671,6 +671,15 @@ luaA_awesome_emit_signal(lua_State *L)
return 0;
}
static int
luaA_panic(lua_State *L)
{
warn("unprotected error in call to Lua API (%s), restarting awesome",
lua_tostring(L, -1));
awesome_restart();
return 0;
}
/** Initialize the Lua VM
* \param xdg An xdg handle to use to get XDG basedir.
*/
@ -694,6 +703,9 @@ luaA_init(xdgHandle* xdg)
L = globalconf.L = luaL_newstate();
/* Set panic function */
lua_atpanic(L, luaA_panic);
luaL_openlibs(L);
luaA_fixups(L);