delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/2000/03/13/10:45:47

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-developers-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-developers-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com
Message-ID: <779F20BCCE5AD31186A50008C75D99791716F7@SILLDN_MAIL1>
From: "Fifer, Eric" <EFifer AT sanwaint DOT com>
To: "'Chris Faylor'" <cgf AT cygnus DOT com>
Cc: "'cygwin-developers AT sourceware DOT cygnus DOT com'"
<cygwin-developers AT sourceware DOT cygnus DOT com>
Subject: RE: some bug fixes
Date: Mon, 13 Mar 2000 15:41:34 -0000
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2448.0)

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01BF8D02.9A77387E
Content-Type: text/plain;
	charset="iso-8859-1"


This is an old thread, but I'd like to try again to get
a minor bug fixed.  I changed the patch so that it doesn't
need to use strcmp on fh->get_name().

With the attached patch, in select.cc (peek_pipe) PeekNamedPipe
should not be called on FH_PIPEW (the write end of a pipe) because
it will fail incorrectly (PeekNamedPipe fails with ACCESS_DENIED
on a handle with only GENERIC_WRITE access).  The remainder of
the patch changes the generic use of FH_PIPE to FH_PIPER and
FH_PIPEW.

This is an example that demonstrates the bug:

#include <sys/select.h>

main()
{
    int fd[2];
    fd_set fde;
    int n;
    struct timeval timeout;

    pipe(fd); /* 0 read, 1 write */
    FD_ZERO(&fde);
    FD_SET(fd[1], &fde);
    timeout.tv_sec = 1; timeout.tv_usec = 0;

    n = select(16, NULL, NULL, &fde, &timeout);
    printf("n = %d\n", n);
}

Thanks.

Eric Fifer


------_=_NextPart_000_01BF8D02.9A77387E
Content-Type: application/octet-stream;
	name="cygwin.pipe.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="cygwin.pipe.patch"

diff -up winsup.orig/cygwin/select.cc winsup/cygwin/select.cc=0A=
--- winsup.orig/cygwin/select.cc	Sun Mar 12 06:30:23 2000=0A=
+++ winsup/cygwin/select.cc	Mon Mar 13 14:29:41 2000=0A=
@@ -426,7 +426,8 @@ peek_pipe (select_record *s, int ignra)=0A=
 	}=0A=
     }=0A=
 =0A=
-  if (!PeekNamedPipe (h, NULL, 0, NULL, (DWORD *) &n, NULL))=0A=
+  if (fh->get_device () !=3D FH_PIPEW &&=0A=
+      !PeekNamedPipe (h, NULL, 0, NULL, (DWORD *) &n, NULL))=0A=
     {=0A=
       select_printf ("%s, PeekNamedPipe failed, %E", fh->get_name =
());=0A=
       n =3D -1;=0A=
diff -up winsup.orig/cygwin/fhandler.cc winsup/cygwin/fhandler.cc=0A=
--- winsup.orig/cygwin/fhandler.cc	Sun Mar 12 06:30:21 2000=0A=
+++ winsup/cygwin/fhandler.cc	Mon Mar 13 14:24:38 2000=0A=
@@ -1456,8 +1456,8 @@ fhandler_dev_null::dump (void)=0A=
 =
/**********************************************************************/=
=0A=
 /* fhandler_pipe */=0A=
 =0A=
-fhandler_pipe::fhandler_pipe (const char *name) :=0A=
-	fhandler_base (FH_PIPE, name)=0A=
+fhandler_pipe::fhandler_pipe (const DWORD devtype, const char *name) =
:=0A=
+	fhandler_base (devtype, name)=0A=
 {=0A=
   set_cb (sizeof *this);=0A=
 }=0A=
diff -up winsup.orig/cygwin/fhandler.h winsup/cygwin/fhandler.h=0A=
--- winsup.orig/cygwin/fhandler.h	Sun Mar 12 06:30:21 2000=0A=
+++ winsup/cygwin/fhandler.h	Mon Mar 13 14:30:25 2000=0A=
@@ -327,7 +327,7 @@ public:=0A=
 class fhandler_pipe: public fhandler_base=0A=
 {=0A=
 public:=0A=
-  fhandler_pipe (const char *name =3D 0);=0A=
+  fhandler_pipe (const DWORD devtype, const char *name =3D 0);=0A=
   off_t lseek (off_t offset, int whence);=0A=
   /* This strange test is due to the fact that we can't rely on=0A=
      Windows shells to "do the right thing" with pipes.  Apparently=0A=
diff -up winsup.orig/cygwin/hinfo.cc winsup/cygwin/hinfo.cc=0A=
--- winsup.orig/cygwin/hinfo.cc	Tue Mar 07 05:33:51 2000=0A=
+++ winsup/cygwin/hinfo.cc	Mon Mar 13 14:33:32 2000=0A=
@@ -261,7 +261,7 @@ hinfo::build_fhandler (int fd, DWORD dev=0A=
       case FH_PIPE:=0A=
       case FH_PIPER:=0A=
       case FH_PIPEW:=0A=
-	fh =3D new (buf) fhandler_pipe (name);=0A=
+	fh =3D new (buf) fhandler_pipe (dev & FH_DEVMASK, name);=0A=
 	break;=0A=
       case FH_SOCKET:=0A=
 	fh =3D new (buf) fhandler_socket (name);=0A=
diff -up winsup.orig/cygwin/pipe.cc winsup/cygwin/pipe.cc=0A=
--- winsup.orig/cygwin/pipe.cc	Thu Feb 24 04:55:15 2000=0A=
+++ winsup/cygwin/pipe.cc	Mon Mar 13 14:27:04 2000=0A=
@@ -30,8 +30,8 @@ make_pipe (int fildes[2], unsigned int p=0A=
     __seterrno ();=0A=
   else=0A=
     {=0A=
-      fhandler_base *fhr =3D dtable.build_fhandler (fdr, FH_PIPE, =
"/dev/piper");=0A=
-      fhandler_base *fhw =3D dtable.build_fhandler (fdw, FH_PIPE, =
"/dev/pipew");=0A=
+      fhandler_base *fhr =3D dtable.build_fhandler (fdr, FH_PIPER, =
"/dev/piper");=0A=
+      fhandler_base *fhw =3D dtable.build_fhandler (fdw, FH_PIPEW, =
"/dev/pipew");=0A=
 =0A=
       int binmode =3D mode & O_TEXT ? 0 : 1;=0A=
       fhr->init (r, GENERIC_READ, binmode);=0A=

------_=_NextPart_000_01BF8D02.9A77387E--

- Raw text -


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