static lua_LHFunction old_linehook = NULL;
static lua_CHFunction old_callhook = NULL;
static void lrestore (void)
{
lua_linehook = old_linehook;
lua_callhook = old_callhook;
old_linehook = NULL;
old_callhook = NULL;
}
static handler lreset (void);
{
return signal (SIGINT, laction);
}
static void lstop (void)
{
lrestore ();
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;
}
In the last case, the two lua_??Function variables will be used to save the pair of hooks in use when the interruption was made. Then, a new pair of hooks is used to make the interpreter stops at a safe point. When the first of these new hooks are reached, the original ones are restored.