12 #define pipe(fds) _pipe(fds, 4096, O_BINARY | O_NOINHERIT)
15 static FILE *do_popen(
struct Popen *
state,
int wr,
const char *program,
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];
43 if (
state->pid == -1) {
51 state->fp = fdopen(pfd, dir);
64 return do_popen(
state, 1, program, args);
69 return do_popen(
state, 0, program, args);
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_close(struct Popen *state)
void G_popen_clear(struct Popen *state)
FILE * G_popen_write(struct Popen *state, const char *program, const char **args)
#define SF_CLOSE_DESCRIPTOR
#define SF_REDIRECT_DESCRIPTOR