diff options
| author | ruki <[email protected]> | 2022-10-09 11:14:30 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-10-09 11:14:56 +0800 |
| commit | 4eab4583144dd0319c33431a557a06905c811ef5 (patch) | |
| tree | 99ff8a2502e2c2c0a0eec7f64ea6dd107f64a681 /core/src/xmake/process | |
| parent | 290921f5b54ff1529388644c296b65e405720f29 (diff) | |
add exclusive mode for debugger
Diffstat (limited to 'core/src/xmake/process')
| -rw-r--r-- | core/src/xmake/process/openv.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/core/src/xmake/process/openv.c b/core/src/xmake/process/openv.c index 5114e263c..fdb0a7f0f 100644 --- a/core/src/xmake/process/openv.c +++ b/core/src/xmake/process/openv.c @@ -30,6 +30,9 @@ */ #include "prefix.h" #include "../io/prefix.h" +#if defined(TB_CONFIG_OS_MACOSX) || defined(TB_CONFIG_OS_LINUX) || defined(TB_CONFIG_OS_BSD) +# include <signal.h> +#endif /* ////////////////////////////////////////////////////////////////////////////////////// * implementation @@ -105,6 +108,7 @@ tb_int_t xm_process_openv(lua_State* lua) tb_process_attr_t attr = {0}; // get option arguments + tb_bool_t exclusive = tb_false; tb_size_t envn = 0; tb_char_t const* envs[1024] = {0}; tb_char_t const* inpath = tb_null; @@ -125,6 +129,13 @@ tb_int_t xm_process_openv(lua_State* lua) attr.flags |= TB_PROCESS_FLAG_DETACH; lua_pop(lua, 1); + // is exclusive? + lua_pushstring(lua, "exclusive"); + lua_gettable(lua, 3); + if (lua_toboolean(lua, -1)) + exclusive = tb_true; + lua_pop(lua, 1); + // get curdir lua_pushstring(lua, "curdir"); lua_gettable(lua, 3); @@ -318,6 +329,16 @@ tb_int_t xm_process_openv(lua_State* lua) // set the new environments if (envn > 0) attr.envp = envs; + /* we need ignore SIGINT and SIGQUIT if we enter exclusive mode + * @see https://github.com/xmake-io/xmake/discussions/2893 + */ +#if defined(SIGINT) + if (exclusive) signal(SIGINT, SIG_IGN); +#endif +#if defined(SIGQUIT) + if (exclusive) signal(SIGQUIT, SIG_IGN); +#endif + // init process tb_process_ref_t process = (tb_process_ref_t)tb_process_init(shellname, argv, &attr); if (process) xm_lua_pushpointer(lua, (tb_pointer_t)process); |
