Merge: doc: fixed some typos and other misc. corrections
[nit.git] / c_src / core__exec._ffi.c
1 /*
2 Extern implementation of Nit module exec
3 */
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <stdint.h>
7 #include "core__exec._ffi.h"
8 #ifdef ANDROID
9 #include <android/log.h>
10 #define PRINT_ERROR(...) (void)__android_log_print(ANDROID_LOG_WARN, "Nit", __VA_ARGS__)
11 #else
12 #define PRINT_ERROR(...) fprintf(stderr, __VA_ARGS__)
13 #endif
14 #line 19 "../lib/core/exec.nit"
15
16
17 #include <stdlib.h>
18 #include <string.h>
19 #include <errno.h>
20 #include <stdio.h>
21 #include <unistd.h>
22 #include <signal.h>
23 #include <sys/types.h>
24
25 #ifdef _WIN32
26 #include <windows.h>
27 #include <fcntl.h>
28 #else
29 #include <sys/wait.h>
30 #endif
31
32 typedef struct se_exec_data se_exec_data_t;
33 struct se_exec_data {
34 #ifdef _WIN32
35 HANDLE h_process;
36 HANDLE h_thread;
37 #endif
38 pid_t id;
39 int running;
40 int status;
41 int in_fd;
42 int out_fd;
43 int err_fd;
44 };
45 long core__exec___CString_system___impl( char* self )
46 {
47 #line 457 "../lib/core/exec.nit"
48
49
50 int status = system(self);
51 #ifndef _WIN32
52 if (WIFSIGNALED(status) && WTERMSIG(status) == SIGINT) {
53 // system exited on SIGINT: in my opinion the user wants the main to be discontinued
54 kill(getpid(), SIGINT);
55 }
56 #endif
57 return status;
58 }