Getting the pipe guard

Christopher Faylor cgf-no-personal-reply-please@cygwin.com
Sun May 21 05:26:00 GMT 2006


On Sat, May 20, 2006 at 09:43:16PM -0400, Lev Bishop wrote:
>Index: select.cc
>===================================================================
>RCS file: /cvs/src/src/winsup/cygwin/select.cc,v
>retrieving revision 1.123
>diff -u -p -d -r1.123 select.cc
>--- select.cc	24 Apr 2006 15:16:45 -0000	1.123
>+++ select.cc	21 May 2006 00:56:04 -0000
>@@ -689,14 +689,18 @@ pipe_cleanup (select_record *, select_st
> int
> fhandler_pipe::ready_for_read (int fd, DWORD howlong)
> {
>-  int res;
>+  int res = true;
>+  const HANDLE w4[2] = {signal_arrived, get_guard ()};
>   if (howlong)
>-    res = true;
>+    {
>+      if (w4[2] && WAIT_OBJECT_0 == WaitForMultipleObjects (2, w4, 0, INFINITE))
>+	{
>+	  set_sig_errno (EINTR);
>+	  return 0;
>+	}
>+    }
>   else
>     res = fhandler_base::ready_for_read (fd, howlong);
>-
>-  if (res)
>-    get_guard ();
>   return res;
> }

The above code seems to be needed but I can't see how it could affect the
non-blocking case since "howlong" is only set in the blocking case.

I've checked in a variation of the above plus some modifications to
pipe.cc which prevent some handle stomping and may make things work
better.

Thanks for the patch.

cgf



More information about the Cygwin-patches mailing list