lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



> Why, when I run the following:

> lua -e "io.stdin:read '*a'"

> do I need to press Ctrl+C twice to escape?

The first control C is handled by the function below, which sets a count hook to trigger at the next virtual opcode; this will call lua_error and generate a backtrace. The sig handler is not reset until this happens, so the second ctrl+C actually terminates the process.

lua.c line 92

static void laction (int i) {
  signal(i, SIG_DFL); /* if another SIGINT happens before lstop,
                              terminate process (default action) */
  lua_sethook(L, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1);
}