From 7484bc31b491fe4cec694386f95962c6f0c0d1d9 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 11 Aug 2017 08:15:47 +0200 Subject: [PATCH] system/FileDescriptor: implement CreatePipe() on Windows --- src/system/FileDescriptor.cxx | 6 ++++++ src/system/FileDescriptor.hxx | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/system/FileDescriptor.cxx b/src/system/FileDescriptor.cxx index 38fa43b2d..d6d2a3b85 100644 --- a/src/system/FileDescriptor.cxx +++ b/src/system/FileDescriptor.cxx @@ -99,6 +99,8 @@ FileDescriptor::OpenNonBlocking(const char *pathname) noexcept return Open(pathname, O_RDWR | O_NONBLOCK); } +#endif + bool FileDescriptor::CreatePipe(FileDescriptor &r, FileDescriptor &w) noexcept { @@ -107,6 +109,8 @@ FileDescriptor::CreatePipe(FileDescriptor &r, FileDescriptor &w) noexcept #ifdef HAVE_PIPE2 const int flags = O_CLOEXEC; const int result = pipe2(fds, flags); +#elif defined(_WIN32) + const int result = _pipe(fds, 512, _O_BINARY); #else const int result = pipe(fds); #endif @@ -119,6 +123,8 @@ FileDescriptor::CreatePipe(FileDescriptor &r, FileDescriptor &w) noexcept return true; } +#ifndef _WIN32 + void FileDescriptor::SetNonBlocking() noexcept { diff --git a/src/system/FileDescriptor.hxx b/src/system/FileDescriptor.hxx index a049ad71d..4c0e1c3d0 100644 --- a/src/system/FileDescriptor.hxx +++ b/src/system/FileDescriptor.hxx @@ -110,9 +110,11 @@ public: #ifndef WIN32 bool OpenNonBlocking(const char *pathname) noexcept; +#endif static bool CreatePipe(FileDescriptor &r, FileDescriptor &w) noexcept; +#ifndef _WIN32 /** * Enable non-blocking mode on this file descriptor. */