This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: select() and named pipes


On Wed, Dec 23, 2009 at 03:12:19AM +0100, Enrico Forestieri wrote:
> On Tue, Dec 22, 2009 at 07:37:14PM -0500, Christopher Faylor wrote:
> > On Tue, Dec 22, 2009 at 11:43:09PM +0100, Enrico Forestieri wrote:
> > >I am experiencing a problem with select() and named pipes in cygwin
> > >1.7.  The attached test case segfaults on the select() call, but works
> > >fine with both cygwin 1.5 and linux.
> > 
> > Thanks for the test case.  This should be fixed in the next Cygwin
> > snapshot but it will not be fixed (of course?) in 1.7.1 which is now
> > available from the Cygwin web site.
> 
> I confirm that with the 20091222 snapshot the crash does not occur
> anymore. However, there's still something wrong. Indeed, running the
> test case in a terminal and issuing "echo foo > /tmp/pipe" from another
> one, the program exits without printing the expected "foo".

Apparently, the problem is due to the O_NONBLOCK flag used in the open()
call. Taking away O_NONBLOCK, everything works.

This bug is causing an infinite loop in an application. The loop can
be reproduced by the slightly modified test case attached here.

When O_NONBLOCK is used, after issuing "echo foo > /tmp/pipe", read()
always returns -1 and sets errno to EAGAIN. However, according to
http://www.opengroup.org/onlinepubs/009695399/functions/read.html
this should only occur when reading from an empty pipe or fifo
and some process has the pipe open for writing and O_NONBLOCK is set.
Here, the fifo is not empty (as reported by select), and thus that
should not happen.

-- 
Enrico

Attachment: readfifo.c
Description: Text document

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]