diff options
author | Michael Forney <mforney@mforney.org> | 2019-05-20 11:26:32 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-05-20 11:38:39 -0700 |
commit | ea6cfe2e8daa30833ebc5fb1e12028b4bfe7f334 (patch) | |
tree | 212716184144fc935473e68a7348c6f2c909ece9 | |
parent | e66a270ab9eaa9036c0fa70f7b2664ad430520a6 (diff) | |
download | cproc-ea6cfe2e8daa30833ebc5fb1e12028b4bfe7f334.tar.xz |
driver: Avoid pipe2 for now, it is not yet standardized
pipe2 is accepted for the next POSIX, but this is not yet released,
and some platforms (in particular macOS) do not yet support it.
-rw-r--r-- | driver.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -17,8 +17,6 @@ #include "util.h" -extern int pipe2(int[2], int); - enum phaseid { PREPROCESS = 1, COMPILE, @@ -149,10 +147,18 @@ spawnphase(struct phase *phase, int *fd, char *input, char *output, bool last) if (*fd != -1) ret = posix_spawn_file_actions_adddup2(&actions, *fd, 0); if (!last) { - if (pipe2(pipefd, O_CLOEXEC) < 0) { + if (pipe(pipefd) < 0) { ret = errno; goto err1; } + if (fcntl(pipefd[0], F_SETFD, FD_CLOEXEC) < 0) { + ret = errno; + goto err2; + } + if (fcntl(pipefd[1], F_SETFD, FD_CLOEXEC) < 0) { + ret = errno; + goto err2; + } ret = posix_spawn_file_actions_adddup2(&actions, pipefd[1], 1); if (ret) goto err2; |