[PATCH] Cygwin: honor the O_PATH flag when opening a FIFO

Ken Brown kbrown@cornell.edu
Thu Jun 27 01:10:00 GMT 2019


Previously fhandler_fifo::open would treat the FIFO as a reader and
would block, waiting for a writer.
---
 winsup/cygwin/fhandler_fifo.cc | 11 ++++++++++-
 winsup/cygwin/release/3.0.8    | 13 +++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 winsup/cygwin/release/3.0.8

diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc
index 5733ec778..9112314fe 100644
--- a/winsup/cygwin/fhandler_fifo.cc
+++ b/winsup/cygwin/fhandler_fifo.cc
@@ -85,11 +85,20 @@ fhandler_fifo::open (int flags, mode_t)
   bool reader, writer, duplexer;
   DWORD open_mode = FILE_FLAG_OVERLAPPED;
 
+  if (flags & O_PATH)
+    {
+      query_open (query_read_attributes);
+      nohandle (true);
+    }
+
   /* Determine what we're doing with this fhandler: reading, writing, both */
   switch (flags & O_ACCMODE)
     {
     case O_RDONLY:
-      reader = true;
+      if (query_open ())
+	reader = false;
+      else
+	reader = true;
       writer = false;
       duplexer = false;
       break;
diff --git a/winsup/cygwin/release/3.0.8 b/winsup/cygwin/release/3.0.8
new file mode 100644
index 000000000..e3734c9b7
--- /dev/null
+++ b/winsup/cygwin/release/3.0.8
@@ -0,0 +1,13 @@
+What's new:
+-----------
+
+
+What changed:
+-------------
+
+
+Bug Fixes
+---------
+
+- Fix a hang when opening a FIFO with O_PATH.
+  Addresses: https://cygwin.com/ml/cygwin-developers/2019-06/msg00001.html
-- 
2.21.0



More information about the Cygwin-patches mailing list