summaryrefslogtreecommitdiff
path: root/lua.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-01-06 11:12:41 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-01-06 11:12:41 -0200
commitdc90d4bce340f987a5048c17699a653f47360711 (patch)
tree7a813584fa4f9ff8b78a4803c5a2f5e3fb473d8d /lua.c
parentf5bc6710309fb368e4bc84a019b8e50e82faab0b (diff)
downloadlua-dc90d4bce340f987a5048c17699a653f47360711.tar.gz
lua-dc90d4bce340f987a5048c17699a653f47360711.tar.bz2
lua-dc90d4bce340f987a5048c17699a653f47360711.zip
when handling signals (^C), deep old hook values.
Diffstat (limited to 'lua.c')
-rw-r--r--lua.c12
1 files 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 @@
1/* 1/*
2** $Id: lua.c,v 1.14 1998/02/11 20:56:05 roberto Exp roberto $ 2** $Id: lua.c,v 1.15 1998/12/28 13:44:54 roberto Exp $
3** Lua stand-alone interpreter 3** Lua stand-alone interpreter
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -33,20 +33,26 @@ typedef void (*handler)(int); /* type for signal actions */
33static void laction (int i); 33static void laction (int i);
34 34
35 35
36static lua_LHFunction old_linehook = NULL;
37static lua_CHFunction old_callhook = NULL;
38
39
36static handler lreset (void) { 40static handler lreset (void) {
37 lua_linehook = NULL;
38 lua_callhook = NULL;
39 return signal(SIGINT, laction); 41 return signal(SIGINT, laction);
40} 42}
41 43
42 44
43static void lstop (void) { 45static void lstop (void) {
46 lua_linehook = old_linehook;
47 lua_callhook = old_callhook;
44 lreset(); 48 lreset();
45 lua_error("interrupted!"); 49 lua_error("interrupted!");
46} 50}
47 51
48 52
49static void laction (int i) { 53static void laction (int i) {
54 old_linehook = lua_linehook;
55 old_callhook = lua_callhook;
50 lua_linehook = (lua_LHFunction)lstop; 56 lua_linehook = (lua_LHFunction)lstop;
51 lua_callhook = (lua_CHFunction)lstop; 57 lua_callhook = (lua_CHFunction)lstop;
52} 58}