This is the mail archive of the cygwin@cygwin.com 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]

Bug: fhandler.cc rev=1.116 source code level bug in fhandler_base::dup (fhandler_base *child)


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/


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