From 0b3b13ba190262592cdbcea17e7b38fb972befde Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 27 Aug 2009 16:04:40 +0200 Subject: [PATCH] luaa: restart awesome on Lua PANIC Signed-off-by: Julien Danjou --- luaa.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/luaa.c b/luaa.c index 6f046931..d4841723 100644 --- a/luaa.c +++ b/luaa.c @@ -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);