--- lua-5.4.0/src/lua.c 2020年06月18日 15:25:54.000000000 +0100 +++ lua-5.4.0-rrt/src/lua.c 2020年08月03日 10:58:57.416419488 +0100 @@ -125,6 +125,21 @@ } +#if defined(LUA_USE_POSIX) /* { */ + +static void sig_catch(int sig, void (*handler)(int)) +{ + struct sigaction sa; + sa.sa_handler = handler; + sa.sa_flags = 0; + sigemptyset(&sa.sa_mask); + sigaction(sig, &sa, NULL); /* ignore error: none possible */ +} + +#else +#define sig_catch signal +#endif /* } */ + /* ** Interface to 'lua_pcall', which sets appropriate message function ** and C-signal handler. Used to run all chunks. @@ -135,9 +150,9 @@ lua_pushcfunction(L, msghandler); /* push message handler */ lua_insert(L, base); /* put it under function and args */ globalL = L; /* to be available to 'laction' */ - signal(SIGINT, laction); /* set C-signal handler */ + sig_catch(SIGINT, laction); /* set C-signal handler */ status = lua_pcall(L, narg, nres, base); - signal(SIGINT, SIG_DFL); /* reset C-signal handler */ + sig_catch(SIGINT, SIG_DFL); /* reset C-signal handler */ lua_remove(L, base); /* remove message handler from the stack */ return status; }