diff options
author | Christopher Faylor <me@cgf.cx> | 2001-07-21 03:20:01 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2001-07-21 03:20:01 +0000 |
commit | a7670c1e828fd3f628aee3c6d77b9c40bf429b0c (patch) | |
tree | e25595b7055f68babbec00191ff0c6804c1ffa94 | |
parent | b34f1c9f7b31a65b9e7ef5cd049f8b2403787553 (diff) | |
download | newlib-a7670c1e828fd3f628aee3c6d77b9c40bf429b0c.zip newlib-a7670c1e828fd3f628aee3c6d77b9c40bf429b0c.tar.gz newlib-a7670c1e828fd3f628aee3c6d77b9c40bf429b0c.tar.bz2 |
* 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.
-rw-r--r-- | winsup/cygwin/ChangeLog | 9 | ||||
-rw-r--r-- | winsup/cygwin/cygheap.cc | 8 | ||||
-rw-r--r-- | winsup/cygwin/dtable.cc | 6 | ||||
-rw-r--r-- | winsup/cygwin/fhandler.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_tty.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/fork.cc | 3 |
6 files changed, 25 insertions, 7 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index bfcd8f0..b1e31f1 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +Fri 20 Jul 2001 11:15:50 PM EDT Christopher Faylor <cgf@cygnus.com> + + * 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 <bradshaw@staff.crosswalk.com> * dir.cc (readdir): Protect FindNextFileA against INVALID_HANDLE_VALUE. diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index 9d1eeeb..3ca185a 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 4fb726e..a5477eb 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 65ef214..e30348a 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 293f4e6..c866e53 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 640623e..4e3c326 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; |