12 #define pipe(fds) _pipe(fds, 4096, O_BINARY|O_NOINHERIT) 15 static FILE *do_popen(
struct Popen *
state,
int wr,
16 const char *program,
const char **args)
18 int which = wr ? 0 : 1;
19 const char *dir = wr ?
"w" :
"r";
27 if (pipe(pipe_fds) < 0)
30 cfd = pipe_fds[wr ? 0 : 1];
31 pfd = pipe_fds[wr ? 1 : 0];
46 if (state->
pid == -1) {
54 state->
fp = fdopen(pfd, dir);
67 return do_popen(state, 1, program, args);
72 return do_popen(state, 0, program, args);
void G_popen_close(struct Popen *state)
FILE * G_popen_write(struct Popen *state, const char *program, const char **args)
#define SF_REDIRECT_DESCRIPTOR
int G_spawn_ex(const char *command,...)
Spawn new process based on command.
FILE * G_popen_read(struct Popen *state, const char *program, const char **args)
void G_popen_clear(struct Popen *state)
#define SF_CLOSE_DESCRIPTOR