[newlib-cygwin] Cygwin: honor the O_PATH flag when opening a FIFO

Ken Brown kbrown@sourceware.org
Thu Jun 27 12:12:00 GMT 2019


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=aa55d22cb55d67d7f77ee9d58f9016c42c3ee495

commit aa55d22cb55d67d7f77ee9d58f9016c42c3ee495
Author: Ken Brown <kbrown@cornell.edu>
Date:   Thu Jun 27 07:46:14 2019 -0400

    Cygwin: honor the O_PATH flag when opening a FIFO
    
    Previously fhandler_fifo::open would treat the FIFO as a reader and
    would block, waiting for a writer.

Diff:
---
 winsup/cygwin/fhandler_fifo.cc | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc
index 737264b..92797ce 100644
--- a/winsup/cygwin/fhandler_fifo.cc
+++ b/winsup/cygwin/fhandler_fifo.cc
@@ -451,11 +451,18 @@ fhandler_fifo::open (int flags, mode_t)
    error_set_errno
   } res;
 
+  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 = true;
       break;
     case O_WRONLY:
       writer = true;
@@ -577,6 +584,8 @@ fhandler_fifo::open (int flags, mode_t)
 	    }
 	}
     }
+  if (query_open ())
+    res = success;
 out:
   if (res == error_set_errno)
     __seterrno ();



More information about the Cygwin-cvs mailing list