open() and named pipes

Christopher Faylor cgf-use-the-mailinglist-please@cygwin.com
Wed Dec 9 15:41:00 GMT 2009


On Wed, Dec 09, 2009 at 03:43:41PM +0100, Enrico Forestieri wrote:
>Sorry for the very late reply and thanks for fixing the return code
>from open(). However, this is still not posix compliant as errno is
>set to ENOENT instead of ENXIO. Indeed, the attached test case prints
>"No process is reading from the other end." on both Linux and Solaris
>but nothing on Cygwin.

The patch below should fix this.  I'll check it in as soon as the latest
version of Cygwin is released.  That should be imminent.

cgf

===================================================================
RCS file: /cvs/uberbaum/winsup/cygwin/fhandler_fifo.cc,v
retrieving revision 1.36
diff -d -u -r1.36 fhandler_fifo.cc
--- fhandler_fifo.cc    31 Oct 2009 13:24:06 -0000      1.36
+++ fhandler_fifo.cc    9 Dec 2009 15:39:54 -0000
@@ -76,6 +76,7 @@
 {
   int res = 1;
   char npname[MAX_PATH];
+  bool set_errno = true;

   fifo_name (npname);
   unsigned low_flags = flags & O_ACCMODE;
@@ -110,7 +111,10 @@
          if (h != INVALID_HANDLE_VALUE)
            wait_state = fifo_ok;
          else if (nonblocking_write)
-           set_errno (ENXIO);
+           {
+             set_errno (ENXIO);
+             set_errno = false;
+           }
          else if ((h = cnp (PIPE_ACCESS_DUPLEX, 1)) != INVALID_HANDLE_VALUE)
            {
              if ((dummy_client = open_nonserver (npname, low_flags, sa_buf))
@@ -130,7 +134,8 @@
        }
       if (h == INVALID_HANDLE_VALUE)
        {
-         __seterrno ();
+         if (set_errno)
+           __seterrno ();
          res = 0;
        }
       else if (!setup_overlapped ())


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list