www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/12/09/09:44:00

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00
X-Spam-Check-By: sourceware.org
Date: Wed, 9 Dec 2009 15:43:41 +0100
From: Enrico Forestieri <forenr AT lyx DOT org>
To: cygwin AT cygwin DOT com
Subject: Re: open() and named pipes
Message-ID: <20091209144340.GA2916@GIOVE>
References: <20081126145052 DOT GB16542 AT sirio DOT sssup DOT it> <20081126173849 DOT GA14783 AT ednor DOT casa DOT cgf DOT cx>
Mime-Version: 1.0
In-Reply-To: <20081126173849.GA14783@ednor.casa.cgf.cx>
User-Agent: Mutt/1.4.2.2i
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

--azLHFNyN32YCQGCU
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Wed, Nov 26, 2008 at 12:38:49PM -0500, Christopher Faylor wrote:
> On Wed, Nov 26, 2008 at 03:50:52PM +0100, Enrico Forestieri wrote:
> >According to
> >http://www.opengroup.org/onlinepubs/000095399/functions/open.html
> >the open() function shall fail and sets errno to ENXIO if
> >O_WRONLY | O_NONBLOCK is set, the named file is a FIFO, and no
> >process has the file open for reading.
> >
> >This is not the case on Cygwin, as demonstrated by the attached
> >test case. I get "This should not happen.", while the same program
> >outputs "No process is reading from the other end." on both Linux
> >and Solaris.
> 
> This should be fixed in the current snapshot.  However, be aware that
> snapshots come from the 1.7.x trunk rather than the 1.5.x

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.

-- 
Enrico

--azLHFNyN32YCQGCU
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="fifobug.c"

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#define FIFONAME "/tmp/xyz.xyz"

int main(void)
{
    int fd;
    if (mkfifo(FIFONAME, 0600) < 0) {
	perror("Error");
	exit(1);
    }
    fd = open(FIFONAME, O_WRONLY | O_NONBLOCK);
    if (fd >= 0) {
	puts("This should not happen.");
	close(fd);
    } else if (errno == ENXIO) {
	puts("No process is reading from the other end.");
    }
    remove(FIFONAME);
    return 0;
}


--azLHFNyN32YCQGCU
Content-Type: text/plain; charset=us-ascii

--
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
--azLHFNyN32YCQGCU--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019