Sv: Sv: Named pipes and multiple writers

Ken Brown
Thu Mar 26 23:19:15 GMT 2020

On 3/26/2020 6:39 PM, Ken Brown via Cygwin wrote:
> On 3/26/2020 6:01 PM, wrote:
>> The ENIXIO occurs when parallel child-processes simultaneously using
>> O_NONBLOCK opening the descriptor.
> This is consistent with my guess that the error is generated by 
> fhandler_fifo::wait.  I have a feeling that read_ready should have been created 
> as a manual-reset event, and that more care is needed to make sure it's set when 
> it should be.
>> I could provide a code-snippet
>> to reproduce it if wanted ?
> Yes, please!

That might not be necessary.  If you're able to build the git repo master 
branch, please try the attached patch.

-------------- next part --------------
>From 279591d91a13616957964256e02344a627b6f558 Mon Sep 17 00:00:00 2001
From: Ken Brown <>
Date: Thu, 26 Mar 2020 19:02:16 -0400
Subject: [PATCH] Cygwin: FIFO: make read_ready a manual-reset event

If a FIFO is open for reading and an attempt is made to open it for
writing with O_NONBLOCK, read_ready must be set in order for open to
succeed.  When read_ready was an auto-reset event, there was a brief
period when read_ready was not set set after a writer opened.  If a
second writer attempted to open the FIFO with O_NONBLOCK during this
period, the attempt would fail.

 winsup/cygwin/ | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/winsup/cygwin/ b/winsup/cygwin/
index 19cd0e507..c05161099 100644
--- a/winsup/cygwin/
+++ b/winsup/cygwin/
@@ -516,7 +516,7 @@ fhandler_fifo::open (int flags, mode_t)
   char npbuf[MAX_PATH];
   __small_sprintf (npbuf, "r-event.%08x.%016X", get_dev (), get_ino ());
-  if (!(read_ready = CreateEvent (sa_buf, false, false, npbuf)))
+  if (!(read_ready = CreateEvent (sa_buf, true, false, npbuf)))
       debug_printf ("CreateEvent for %s failed, %E", npbuf);
       res = error_set_errno;

More information about the Cygwin mailing list