cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

commit ea6cfe2e8daa30833ebc5fb1e12028b4bfe7f334
parent e66a270ab9eaa9036c0fa70f7b2664ad430520a6
Author: Michael Forney <mforney@mforney.org>
Date:   Mon, 20 May 2019 11:26:32 -0700

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.

Diffstat:
Mdriver.c | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/driver.c b/driver.c @@ -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;