lib/std/exec: `signal` will forward ^C (SIGINT) to the main program
authorJean Privat <jean@pryen.org>
Fri, 20 Mar 2015 02:01:49 +0000 (09:01 +0700)
committerJean Privat <jean@pryen.org>
Sat, 21 Mar 2015 03:14:46 +0000 (10:14 +0700)
Signed-off-by: Jean Privat <jean@pryen.org>

lib/standard/exec_nit.c
lib/standard/exec_nit.h

index 317e909..5b5ffbb 100644 (file)
@@ -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);
+       }
+}
index c6a59d4..fbd040a 100644 (file)
@@ -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)