From dc90d4bce340f987a5048c17699a653f47360711 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 6 Jan 1999 11:12:41 -0200 Subject: [PATCH] when handling signals (^C), deep old hook values. --- lua.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lua.c b/lua.c index c7f22188..576d34fe 100644 --- a/lua.c +++ b/lua.c @@ -1,5 +1,5 @@ /* -** $Id: lua.c,v 1.14 1998/02/11 20:56:05 roberto Exp roberto $ +** $Id: lua.c,v 1.15 1998/12/28 13:44:54 roberto Exp $ ** Lua stand-alone interpreter ** See Copyright Notice in lua.h */ @@ -33,20 +33,26 @@ typedef void (*handler)(int); /* type for signal actions */ static void laction (int i); +static lua_LHFunction old_linehook = NULL; +static lua_CHFunction old_callhook = NULL; + + static handler lreset (void) { - lua_linehook = NULL; - lua_callhook = NULL; return signal(SIGINT, laction); } static void lstop (void) { + lua_linehook = old_linehook; + lua_callhook = old_callhook; lreset(); lua_error("interrupted!"); } static void laction (int i) { + old_linehook = lua_linehook; + old_callhook = lua_callhook; lua_linehook = (lua_LHFunction)lstop; lua_callhook = (lua_CHFunction)lstop; }