[mod_cgi] fix pipe_cloexec() when no O_CLOEXEC

This commit is contained in:
Glenn Strauss 2016-10-13 03:43:50 -04:00
parent 7f4e156e5f
commit 9173d9aa7d
1 changed files with 6 additions and 1 deletions

View File

@ -39,7 +39,12 @@
#ifdef O_CLOEXEC
#define pipe_cloexec(pipefd) pipe2((pipefd), O_CLOEXEC)
#elif defined FD_CLOEXEC
#define pipe_cloexec(pipefd) (0 == pipe(pipefd) ? fcntl(fd, F_SETFD, FD_CLOEXEC) : -1)
#define pipe_cloexec(pipefd) \
( 0 == pipe(pipefd) \
&& 0 == fcntl(pipefd[0], F_SETFD, FD_CLOEXEC) \
&& 0 == fcntl(pipefd[1], F_SETFD, FD_CLOEXEC) \
? 0 \
: -1)
#else
#define pipe_cloexec(pipefd) pipe(pipefd)
#endif