Commit 7484bc31 authored by Max Kellermann's avatar Max Kellermann

system/FileDescriptor: implement CreatePipe() on Windows

parent 5a495cc1
...@@ -99,6 +99,8 @@ FileDescriptor::OpenNonBlocking(const char *pathname) noexcept ...@@ -99,6 +99,8 @@ FileDescriptor::OpenNonBlocking(const char *pathname) noexcept
return Open(pathname, O_RDWR | O_NONBLOCK); return Open(pathname, O_RDWR | O_NONBLOCK);
} }
#endif
bool bool
FileDescriptor::CreatePipe(FileDescriptor &r, FileDescriptor &w) noexcept FileDescriptor::CreatePipe(FileDescriptor &r, FileDescriptor &w) noexcept
{ {
...@@ -107,6 +109,8 @@ FileDescriptor::CreatePipe(FileDescriptor &r, FileDescriptor &w) noexcept ...@@ -107,6 +109,8 @@ FileDescriptor::CreatePipe(FileDescriptor &r, FileDescriptor &w) noexcept
#ifdef HAVE_PIPE2 #ifdef HAVE_PIPE2
const int flags = O_CLOEXEC; const int flags = O_CLOEXEC;
const int result = pipe2(fds, flags); const int result = pipe2(fds, flags);
#elif defined(_WIN32)
const int result = _pipe(fds, 512, _O_BINARY);
#else #else
const int result = pipe(fds); const int result = pipe(fds);
#endif #endif
...@@ -119,6 +123,8 @@ FileDescriptor::CreatePipe(FileDescriptor &r, FileDescriptor &w) noexcept ...@@ -119,6 +123,8 @@ FileDescriptor::CreatePipe(FileDescriptor &r, FileDescriptor &w) noexcept
return true; return true;
} }
#ifndef _WIN32
void void
FileDescriptor::SetNonBlocking() noexcept FileDescriptor::SetNonBlocking() noexcept
{ {
......
...@@ -110,9 +110,11 @@ public: ...@@ -110,9 +110,11 @@ public:
#ifndef WIN32 #ifndef WIN32
bool OpenNonBlocking(const char *pathname) noexcept; bool OpenNonBlocking(const char *pathname) noexcept;
#endif
static bool CreatePipe(FileDescriptor &r, FileDescriptor &w) noexcept; static bool CreatePipe(FileDescriptor &r, FileDescriptor &w) noexcept;
#ifndef _WIN32
/** /**
* Enable non-blocking mode on this file descriptor. * Enable non-blocking mode on this file descriptor.
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment