Merge with 0.7
[prosody.git] / util-src / signal.c
index 4bda69d81451edf33d2d0714021117d43c48d96d..2d13383fbd2f8115b6454dc9f42db465a787b49d 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * signal.c -- Signal Handler Library for Lua
  *
- * Version: 1.000
+ * Version: 1.000+changes
  *
- * Copyright (C) 2007  Patrick J. Donnelly (batrick@unm.edu)
+ * Copyright (C) 2007  Patrick J. Donnelly (batrick@batbytes.com)
  *
  * This software is distributed under the same license as Lua 5.0:
  *
@@ -27,7 +27,7 @@
 */
 
 #include <signal.h>
-#include <malloc.h>
+#include <stdlib.h>
 
 #include "lua.h"
 #include "lauxlib.h"
@@ -165,6 +165,9 @@ static struct signal_event *last_event = NULL;
 
 static void sighook(lua_State *L, lua_Debug *ar)
 {
+  /* restore the old hook */
+  lua_sethook(L, Hsig, Hmask, Hcount);
+
   lua_pushstring(L, LUA_SIGNAL);
   lua_gettable(L, LUA_REGISTRYINDEX);
 
@@ -180,8 +183,6 @@ static void sighook(lua_State *L, lua_Debug *ar)
 
   lua_pop(L, 1); /* pop lua_signal table */
 
-  /* restore the old hook */
-  lua_sethook(L, Hsig, Hmask, Hcount);
 }
 
 static void handle(int sig)