diff options
author | Christopher Faylor <me@cgf.cx> | 2001-09-14 04:49:00 +0400 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2001-09-14 04:49:00 +0400 |
commit | e2e078278cc951344fc5c0a976715bd1fe11f2d8 (patch) | |
tree | afd6de5d0a5ee0c2778c384423f7a59fd38ccd44 /winsup/cygwin/fork.cc | |
parent | 3e2d8af0b9a8df7b9b1230d35f3e838d3efbfb33 (diff) |
* cygheap.cc (dup_now): New function.
(cygheap_setup_for_child): Accept new argument controlling whether to delay
copying of cygheap to shared memory region.
(cygheap_setup_for_child_cleanup): Accept new arguments controlling whether to
copy cygheap at this point.
* cygheap.h: Reflect above changes.
* fork.cc (fork_parent): Break copying of cygheap into two parts when
fork_fixup is required so that the child can see the parent's changes.
(vfork): Do stack cleanup prior to forcing a fork error.
* spawn.cc (spawn_guts): Ditto.
Diffstat (limited to 'winsup/cygwin/fork.cc')
-rw-r--r-- | winsup/cygwin/fork.cc | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index 3998cb56b..83e25393f 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -464,7 +464,8 @@ fork_parent (HANDLE& hParent, dll *&first_dll, syscall_printf ("CreateProcess (%s, %s, 0, 0, 1, %x, 0, 0, %p, %p)", myself->progname, myself->progname, c_flags, &si, &pi); __malloc_lock (_reent_clib ()); - cygheap_setup_for_child (&ch); + void *newheap; + newheap = cygheap_setup_for_child (&ch,cygheap->fdtab.need_fixup_before ()); rc = CreateProcess (myself->progname, /* image to run */ myself->progname, /* what we send in arg0 */ allow_ntsec ? sec_user (sa_buf) : &sec_none_nih, @@ -477,7 +478,6 @@ fork_parent (HANDLE& hParent, dll *&first_dll, &pi); CloseHandle (hParent); - cygheap_setup_for_child_cleanup (&ch); if (!rc) { @@ -489,14 +489,18 @@ fork_parent (HANDLE& hParent, dll *&first_dll, if (cygheap->user.impersonated && cygheap->user.token != INVALID_HANDLE_VALUE) ImpersonateLoggedOnUser (cygheap->user.token); + cygheap_setup_for_child_cleanup (newheap, &ch, 0); return -1; } /* Fixup the parent datastructure if needed and resume the child's main thread. */ - if (cygheap->fdtab.need_fixup_before ()) + if (!cygheap->fdtab.need_fixup_before ()) + cygheap_setup_for_child_cleanup (newheap, &ch, 0); + else { cygheap->fdtab.fixup_before_fork (pi.dwProcessId); + cygheap_setup_for_child_cleanup (newheap, &ch, 1); ResumeThread (pi.hThread); } @@ -718,6 +722,12 @@ vfork () cygheap->fdtab.vfork_parent_restore (); vf = get_vfork_val (); + + __asm__ volatile ("movl %%esp,%0": "=r" (esp):); + for (pp = (char **)vf->frame, esp = vf->vfork_esp; + esp <= vf->vfork_ebp + 1; pp++, esp++) + *esp = *pp; + if (vf->pid < 0) { int exitval = -vf->pid; @@ -725,11 +735,6 @@ vfork () exit (exitval); } - __asm__ volatile ("movl %%esp,%0": "=r" (esp):); - for (pp = (char **)vf->frame, esp = vf->vfork_esp; - esp <= vf->vfork_ebp + 1; pp++, esp++) - *esp = *pp; - return vf->pid; #endif } |