1 /* This file is part of NIT ( http://www.nitlanguage.org ).
3 * Copyright 2004-2008 Jean Privat <jean@pryen.org>
5 * This file is free software, which comes along with NIT. This software is
6 * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
7 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
8 * PARTICULAR PURPOSE. You can modify it is you want, provided this header
9 * is kept unaltered, and a notification of the changes is added.
10 * You are allowed to redistribute it and sell it, alone or is a part of
20 se_exec_data_t
* exec_Process_Process_basic_exec_execute_4(void *s
, char *prog
, char *args
, int len
, int pipeflag
) {
21 se_exec_data_t
* result
= NULL
;
27 int res
= pipe(in_fd
);
29 fprintf( stderr
, "Pipe init failed in Process:basic_exec_execute: %s\n", strerror( errno
) );
34 int res
= pipe(out_fd
);
36 fprintf( stderr
, "Pipe init failed in Process:basic_exec_execute: %s\n", strerror( errno
) );
41 int res
= pipe(err_fd
);
43 fprintf( stderr
, "Pipe init failed in Process:basic_exec_execute: %s\n", strerror( errno
) );
51 char **arg
= malloc(sizeof(char*) * (len
+1));
92 result
= (se_exec_data_t
*)malloc(sizeof(se_exec_data_t
));
97 result
->in_fd
= in_fd
[1];
104 result
->out_fd
= out_fd
[0];
111 result
->err_fd
= err_fd
[0];
120 int exec_NativeProcess_NativeProcess_is_finished_0(void*d
) {
121 se_exec_data_t
*data
= (se_exec_data_t
*)d
;
125 int id
= waitpid(data
->id
, &status
, WNOHANG
);
127 /* child is finished */
128 result
= (int)(id
== data
->id
);
129 data
->status
= WEXITSTATUS(status
);
139 void exec_NativeProcess_NativeProcess_wait_0(void*d
) {
140 se_exec_data_t
*data
= (se_exec_data_t
*)d
;
143 waitpid(data
->id
, &status
, 0);
144 data
->status
= WEXITSTATUS(status
);