diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index bfcd8f013..b1e31f17d 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +Fri 20 Jul 2001 11:15:50 PM EDT Christopher Faylor + + * cygheap.cc (cygheap_fixup_in_child): Attempt Win95 workaround. + * dtable.cc (dtable::dup_worker): Add debugging output. + (dtable::vfork_child_dup): Correctly set close_on_exec. + * fhandler.cc (fhandler_base::fork_fixup): Don't mess with handle if + there is no need to get it from the parent. + * fhandler_tty.cc (fhandler_tty_common::close): Add debugging output. + Fri 20 Jul 2001 09:15:00 Mark Bradshaw * dir.cc (readdir): Protect FindNextFileA against INVALID_HANDLE_VALUE. diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index 9d1eeeb7e..3ca185ad9 100644 --- a/winsup/cygwin/cygheap.cc +++ b/winsup/cygwin/cygheap.cc @@ -74,7 +74,7 @@ cygheap_setup_for_child (child_info *ci) newcygheap = MapViewOfFileEx (ci->cygheap_h, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0, NULL); if (!VirtualAlloc (newcygheap, n, MEM_COMMIT, PAGE_READWRITE)) - api_fatal ("couldn't allocate new heap for child, %E"); + api_fatal ("couldn't allocate new cygwin heap for child, %E"); memcpy (newcygheap, cygheap, n); UnmapViewOfFile (newcygheap); ci->cygheap = cygheap; @@ -96,9 +96,11 @@ cygheap_fixup_in_child (child_info *ci, bool execed) DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE)) cygheap_h = ci->cygheap_h; #endif + VirtualFree (cygheap, CYGHEAPSIZE, MEM_DECOMMIT); + VirtualFree (cygheap, 0, MEM_RELEASE); if (MapViewOfFileEx (ci->cygheap_h, FILE_MAP_READ | FILE_MAP_WRITE, - 0, 0, 0, cygheap) != cygheap) - api_fatal ("Couldn't allocate space for child's heap from %p, to %p, %E", + 0, 0, CYGHEAPSIZE, cygheap) != cygheap) + api_fatal ("Couldn't allocate space for child's cygwin heap from %p, to %p, %E", cygheap, cygheap_max); ForceCloseHandle1 (ci->cygheap_h, passed_cygheap_h); diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index 4fb726e4d..a5477eb98 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -337,6 +337,7 @@ dtable::dup_worker (fhandler_base *oldfh) newfh->set_close_on_exec_flag (0); MALLOC_CHECK; + debug_printf ("duped '%s' old %p, new %p", oldfh->get_name (), oldfh->get_io_handle (), newfh->get_io_handle ()); return newfh; } @@ -534,7 +535,9 @@ dtable::vfork_child_dup () for (size_t i = 0; i < size; i++) if (not_open (i)) continue; - else if ((newtable[i] = dup_worker (fds[i])) == NULL) + else if ((newtable[i] = dup_worker (fds[i])) != NULL) + newtable[i]->set_close_on_exec (fds[i]->get_close_on_exec ()); + else { res = 0; set_errno (EBADF); @@ -568,6 +571,7 @@ dtable::vfork_child_fixup () { if (!fds_on_hold) return; + debug_printf ("here"); fhandler_base **saveme = fds; fds = fds_on_hold; diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 65ef21411..e30348ac8 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -1542,7 +1542,9 @@ fhandler_base::set_inheritance (HANDLE &h, int not_inheriting, const char *namep void fhandler_base::fork_fixup (HANDLE parent, HANDLE &h, const char *name) { - if (!DuplicateHandle (parent, h, hMainProc, &h, 0, !get_close_on_exec (), + if (!get_close_on_exec ()) + debug_printf ("handle %p already opened", h); + else if (!DuplicateHandle (parent, h, hMainProc, &h, 0, !get_close_on_exec (), DUPLICATE_SAME_ACCESS)) system_printf ("%s - %E, handle %s<%p>", get_name (), name, h); } diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 293f4e636..c866e5357 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -1014,7 +1014,7 @@ fhandler_tty_common::close () termios_printf ("CloseHandle (get_output_handle ()<%p>), %E", get_output_handle ()); inuse = NULL; - termios_printf ("tty%d closed", ttynum); + termios_printf ("tty%d <%p,%p> closed", ttynum, get_handle (), get_output_handle ()); return 0; } diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index 640623e3b..4e3c32668 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -245,7 +245,8 @@ fork_child (HANDLE& hParent, dll *&first_dll, bool& load_dlls) sync_with_parent ("after longjmp.", TRUE); ProtectHandle (hParent); - sigproc_printf ("hParent %p, child 1 first_dll %p, load_dlls %d\n", hParent, first_dll, load_dlls); + sigproc_printf ("hParent %p, child 1 first_dll %p, load_dlls %d\n", hParent, + first_dll, load_dlls); #ifdef DEBUGGING char c;