From ea6cfe2e8daa30833ebc5fb1e12028b4bfe7f334 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Mon, 20 May 2019 11:26:32 -0700 Subject: 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. --- driver.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/driver.c b/driver.c index 3f5ee1e..b274365 100644 --- 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; -- cgit v1.2.3