From: Jean Privat Date: Fri, 20 Mar 2015 02:01:49 +0000 (+0700) Subject: lib/std/exec: `signal` will forward ^C (SIGINT) to the main program X-Git-Tag: v0.7.3~17^2 X-Git-Url: http://nitlanguage.org lib/std/exec: `signal` will forward ^C (SIGINT) to the main program Signed-off-by: Jean Privat --- diff --git a/lib/standard/exec_nit.c b/lib/standard/exec_nit.c index 317e909..5b5ffbb 100644 --- a/lib/standard/exec_nit.c +++ b/lib/standard/exec_nit.c @@ -142,3 +142,11 @@ void exec_NativeProcess_NativeProcess_wait_0(void*d) { data->running = 0; } } + +int string_NativeString_NativeString_system_0(const char *cmd) { + int status = system(cmd); + if (WIFSIGNALED(status) && WTERMSIG(status) == SIGINT) { + // cmd exited on SIGINT: in my opinion the user wants the main to be discontinued + kill(getpid(), SIGINT); + } +} diff --git a/lib/standard/exec_nit.h b/lib/standard/exec_nit.h index c6a59d4..fbd040a 100644 --- a/lib/standard/exec_nit.h +++ b/lib/standard/exec_nit.h @@ -31,7 +31,7 @@ struct se_exec_data { se_exec_data_t* exec_Process_Process_basic_exec_execute_4(void *, char *, char *, int, int); -#define string_NativeString_NativeString_system_0(self) (system(self)) +int string_NativeString_NativeString_system_0(const char*); #define exec_NativeProcess_NativeProcess_id_0(self) (((se_exec_data_t*)self)->id) #define exec_NativeProcess_NativeProcess_status_0(self) (((se_exec_data_t*)self)->status)