* 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.
This commit is contained in:
Christopher Faylor 2001-07-21 03:20:01 +00:00
parent b34f1c9f7b
commit a7670c1e82
6 changed files with 25 additions and 7 deletions

View File

@ -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.

View File

@ -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);

View File

@ -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;

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;