diff options
author | Christopher Faylor <me@cgf.cx> | 2012-05-15 02:42:56 +0400 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2012-05-15 02:42:56 +0400 |
commit | 3de7be4c1debaa8fcd27f8fc15509179fdb37b9f (patch) | |
tree | 4172968a5e085465b58b538e6401f6ecdb92b2a6 /winsup/cygwin/dcrt0.cc | |
parent | 77009cee1e0410a146ed4f7090e01c8a56cba670 (diff) |
* DevNotes: Add entry cgf-000007.
* child_info.h (child_info_spawn::parent_winpid): Declare new field.
(child_info_spawn::get_parent_handle): Declare new function.
* dcrt0.cc (child_info_spawn::get_parent_handle): Define new function.
(child_info_spawn::handle_spawn): Recreate parent handle if possible when
dynamically loaded. Don't mess with parent handle if it's NULL.
* spawn.cc (child_info_spawn::worker): Set parent_winpid appropriately.
Diffstat (limited to 'winsup/cygwin/dcrt0.cc')
-rw-r--r-- | winsup/cygwin/dcrt0.cc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index aea2a564b..e28aecde9 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -625,13 +625,24 @@ child_info_fork::handle_fork () api_fatal ("recreate_mmaps_after_fork_failed"); } +bool +child_info_spawn::get_parent_handle () +{ + parent = OpenProcess (PROCESS_VM_READ, false, parent_winpid); + moreinfo->myself_pinfo = NULL; + return !!parent; +} + void child_info_spawn::handle_spawn () { extern void fixup_lockf_after_exec (); HANDLE h; - cygheap_fixup_in_child (true); - memory_init (false); + if (!dynamically_loaded || get_parent_handle ()) + { + cygheap_fixup_in_child (true); + memory_init (false); + } if (!moreinfo->myself_pinfo || !DuplicateHandle (GetCurrentProcess (), moreinfo->myself_pinfo, GetCurrentProcess (), &h, 0, @@ -669,7 +680,7 @@ child_info_spawn::handle_spawn () Otherwise, we no longer need this handle so close it. Need to do this after debug_fixup_after_fork_exec or DEBUGGING handling of handles might get confused. */ - if (type != _CH_EXEC) + if (type != _CH_EXEC && child_proc_info->parent) { CloseHandle (child_proc_info->parent); child_proc_info->parent = NULL; |