delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-Spam-Check-By: | sourceware.org |
Date: | Wed, 26 Nov 2008 15:50:52 +0100 |
From: | Enrico Forestieri <forenr AT lyx DOT org> |
To: | cygwin AT cygwin DOT com |
Subject: | open() and named pipes |
Message-ID: | <20081126145052.GB16542@sirio.sssup.it> |
Mime-Version: | 1.0 |
User-Agent: | Mutt/1.4.2.1i |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.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 |
--9jxsPFA5p3P2qPhR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. -- Enrico --9jxsPFA5p3P2qPhR Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="openfifo.c" #include <stdio.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; } --9jxsPFA5p3P2qPhR Content-Type: text/plain; charset=us-ascii -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ --9jxsPFA5p3P2qPhR--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |