X-Git-Url: http://nitlanguage.org diff --git a/c_src/exec_nit.c b/c_src/exec_nit.c index 69aa0e4..c808105 100644 --- a/c_src/exec_nit.c +++ b/c_src/exec_nit.c @@ -14,19 +14,36 @@ #include "exec_nit.h" #include #include +#include +#include -se_exec_data_t* exec_Process_Process_basic_exec_execute_4(Process s, char *prog, char *args, int len, int pipeflag) { +se_exec_data_t* exec_Process_Process_basic_exec_execute_4(void *s, char *prog, char *args, int len, int pipeflag) { se_exec_data_t* result = NULL; int id; int in_fd[2]; int out_fd[2]; int err_fd[2]; - if (pipeflag & 1) - pipe(in_fd); - if (pipeflag & 2) - pipe(out_fd); - if (pipeflag & 4) - pipe(err_fd); + if (pipeflag & 1) { + int res = pipe(in_fd); + if ( res == -1 ) { + fprintf( stderr, "Pipe init failed in Process:basic_exec_execute: %s\n", strerror( errno ) ); + exit(1); + } + } + if (pipeflag & 2) { + int res = pipe(out_fd); + if ( res == -1 ) { + fprintf( stderr, "Pipe init failed in Process:basic_exec_execute: %s\n", strerror( errno ) ); + exit(1); + } + } + if (pipeflag & 4) { + int res = pipe(err_fd); + if ( res == -1 ) { + fprintf( stderr, "Pipe init failed in Process:basic_exec_execute: %s\n", strerror( errno ) ); + exit(1); + } + } id = fork(); if (id == 0) @@ -96,6 +113,7 @@ se_exec_data_t* exec_Process_Process_basic_exec_execute_4(Process s, char *prog, } else result->err_fd = -1; } + return result; }