diff options
| author | ruki <[email protected]> | 2024-03-28 23:02:26 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-03-28 23:02:26 +0800 |
| commit | d66e57323f260bbac3d20ac3e0bb1f281d02515c (patch) | |
| tree | b0967ca2f8a9b39222dd8e080f6c80aa7615c9c9 /core/src | |
| parent | 024b14ed93b1bc7e3b30d8dc68105ce2cb5016d6 (diff) | |
fix error for windows
Diffstat (limited to 'core/src')
| -rw-r--r-- | core/src/xmake/os/signal.c | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/core/src/xmake/os/signal.c b/core/src/xmake/os/signal.c index 3955dc5d3..5d3fa5e3c 100644 --- a/core/src/xmake/os/signal.c +++ b/core/src/xmake/os/signal.c @@ -57,44 +57,41 @@ static lua_State* g_lua = tb_null; /* ////////////////////////////////////////////////////////////////////////////////////// * private implementation */ -static tb_void_t xm_os_signal_handler_impl(tb_int_t signo_native) +static tb_void_t xm_os_signal_handler_impl(tb_int_t signo) { // do callback(signo) lua_State* lua = g_lua; if (lua) { - tb_int_t signo = -1; - switch (signo_native) - { -#ifdef SIGINT - case SIGINT: - signo = XM_OS_SIGINT; - break; -#endif - default: - break; - } - if (signo >= 0) - { - tb_char_t name[64] = {0}; - tb_snprintf(name, sizeof(name), "_SIGNAL_HANDLER_%d", signo); - lua_getglobal(lua, name); - lua_pushinteger(lua, signo); - lua_call(lua, 1, 0); - } + tb_char_t name[64] = {0}; + tb_snprintf(name, sizeof(name), "_SIGNAL_HANDLER_%d", signo); + lua_getglobal(lua, name); + lua_pushinteger(lua, signo); + lua_call(lua, 1, 0); } } #if defined(TB_CONFIG_OS_WINDOWS) -static BOOL WINAPI xm_os_signal_handler(DWORD signo) +static BOOL WINAPI xm_os_signal_handler(DWORD ctrl_type) { - xm_os_signal_handler_impl((tb_int_t)signo) + if (ctrl_type == CTRL_C_EVENT) + xm_os_signal_handler_impl(XM_OS_SIGINT); return TRUE; } #elif defined(SIGINT) -static tb_void_t xm_os_signal_handler(tb_int_t signo) +static tb_void_t xm_os_signal_handler(tb_int_t signo_native) { - xm_os_signal_handler_impl(signo); + tb_int_t signo = -1; + switch (signo_native) + { + case SIGINT: + signo = XM_OS_SIGINT; + break; + default: + break; + } + if (signo >= 0) + xm_os_signal_handler_impl(signo); } #endif |
