delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/05/22/12:39:53

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
Message-ID: <001101c201a8$2148fc40$df250b93@ALASTIMSON>
From: "Leo Kuznetsov" <Leo DOT Kuznetsov AT windriver DOT com>
To: <cygwin AT cygwin DOT com>
Cc: "Richard Levien" <Kiwi AT mail DOT wrs DOT com>
Subject: Bug: fhandler.cc rev=1.116 source code level bug in fhandler_base::dup (fhandler_base *child)
Date: Wed, 22 May 2002 08:48:33 -0700
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

Hi,

I might be wrong but it looks like:

In the function below
------------------------
  if (get_nohandle ())
    nh = NULL;        // NULL == 0 and is a valid (but possibly closed) handle

------------------------
MUST BE
------------------------
  if (get_nohandle ())
    nh = (HANDLE)-1;  // or better yet INVALID_HANDLE_VALUE

=========================
Otherwise dup(dup(-1)) == dup(0) and
sets an error if handle 0 is closed.
(This is excatly the case with recursive invocation
of gmake jobs with stdio redirected to pipes)...

---------------------------------

FILE: fhandler.cc
LINE: ~886

int
fhandler_base::dup (fhandler_base *child)
{
  debug_printf ("in fhandler_base dup");

  HANDLE nh;
  if (get_nohandle ())
    nh = NULL;
  else if (!DuplicateHandle (hMainProc, get_handle(), hMainProc, &nh, 0, TRUE,
DUPLICATE_SAME_ACCESS))
    {
      system_printf ("dup(%s) failed, handle %x, %E",
     get_name (), get_handle());
      __seterrno ();
      return -1;
    }

  child->set_io_handle (nh);
  return 0;
}



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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