Provide an alternative to pipe2() on non-Linux systems
This commit is contained in:
parent
93a0b60b6e
commit
767fb175b1
10
src/pipe.h
10
src/pipe.h
|
|
@ -42,8 +42,16 @@ public:
|
||||||
Pipe()
|
Pipe()
|
||||||
{
|
{
|
||||||
// construct the pipe
|
// construct the pipe
|
||||||
|
#ifdef _GNU_SOURCE
|
||||||
if (pipe2(_fds, O_CLOEXEC) == 0) return;
|
if (pipe2(_fds, O_CLOEXEC) == 0) return;
|
||||||
|
#else
|
||||||
|
if (
|
||||||
|
pipe(_fds) == 0 &&
|
||||||
|
fcntl(_fds[0], F_SETFD, FD_CLOEXEC) == 0 &&
|
||||||
|
fcntl(_fds[1], F_SETFD, FD_CLOEXEC) == 0
|
||||||
|
) return;
|
||||||
|
#endif
|
||||||
|
|
||||||
// something went wrong
|
// something went wrong
|
||||||
throw std::runtime_error(strerror(errno));
|
throw std::runtime_error(strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue