mirror of
https://github.com/lua/lua
synced 2024-11-23 13:19:57 +03:00
when handling signals (^C), deep old hook values.
This commit is contained in:
parent
f5bc671030
commit
dc90d4bce3
12
lua.c
12
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
|
** Lua stand-alone interpreter
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -33,20 +33,26 @@ typedef void (*handler)(int); /* type for signal actions */
|
|||||||
static void laction (int i);
|
static void laction (int i);
|
||||||
|
|
||||||
|
|
||||||
|
static lua_LHFunction old_linehook = NULL;
|
||||||
|
static lua_CHFunction old_callhook = NULL;
|
||||||
|
|
||||||
|
|
||||||
static handler lreset (void) {
|
static handler lreset (void) {
|
||||||
lua_linehook = NULL;
|
|
||||||
lua_callhook = NULL;
|
|
||||||
return signal(SIGINT, laction);
|
return signal(SIGINT, laction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void lstop (void) {
|
static void lstop (void) {
|
||||||
|
lua_linehook = old_linehook;
|
||||||
|
lua_callhook = old_callhook;
|
||||||
lreset();
|
lreset();
|
||||||
lua_error("interrupted!");
|
lua_error("interrupted!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void laction (int i) {
|
static void laction (int i) {
|
||||||
|
old_linehook = lua_linehook;
|
||||||
|
old_callhook = lua_callhook;
|
||||||
lua_linehook = (lua_LHFunction)lstop;
|
lua_linehook = (lua_LHFunction)lstop;
|
||||||
lua_callhook = (lua_CHFunction)lstop;
|
lua_callhook = (lua_CHFunction)lstop;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user