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/spawn.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/spawn.cc')
-rw-r--r-- | winsup/cygwin/spawn.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 1e443cb30..248dd426e 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -590,6 +590,7 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv, syscall_printf ("spawn_guts null_app_name %d (%s, %.132s)", null_app_name, runpath, one_line.buf); + void *newheap; cygbench ("spawn-guts"); if (!hToken) { @@ -597,7 +598,7 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv, /* FIXME: This leaks a handle in the CreateProcessAsUser case since the child process doesn't know about cygwin_mount_h. */ ciresrv.mount_h = cygwin_mount_h; - cygheap_setup_for_child (&ciresrv); + newheap = cygheap_setup_for_child (&ciresrv, cygheap->fdtab.need_fixup_before ()); rc = CreateProcess (runpath, /* image name - with full path */ one_line.buf, /* what was passed to exec */ /* process security attrs */ @@ -659,7 +660,7 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv, strcat (wstname, dskname); si.lpDesktop = wstname; - cygheap_setup_for_child (&ciresrv); + newheap = cygheap_setup_for_child (&ciresrv, cygheap->fdtab.need_fixup_before ()); rc = CreateProcessAsUser (hToken, runpath, /* image name - with full path */ one_line.buf, /* what was passed to exec */ @@ -682,7 +683,6 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv, MALLOC_CHECK; if (envblock) free (envblock); - cygheap_setup_for_child_cleanup (&ciresrv); MALLOC_CHECK; /* Set errno now so that debugging messages from it appear before our @@ -694,14 +694,18 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv, syscall_printf ("CreateProcess failed, %E"); if (spr) ForceCloseHandle (spr); + cygheap_setup_for_child_cleanup (newheap, &ciresrv, 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, &ciresrv, 0); + else { cygheap->fdtab.fixup_before_exec (pi.dwProcessId); + cygheap_setup_for_child_cleanup (newheap, &ciresrv, 1); if (mode == _P_OVERLAY) ResumeThread (pi.hThread); } |