diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 5c5a280cc..49b7a44ae 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -631,8 +631,6 @@ child_info_spawn::handle_spawn () if (!dynamically_loaded || get_parent_handle ()) { cygheap_fixup_in_child (true); - if (dynamically_loaded) - moreinfo->myself_pinfo = NULL; memory_init (); } diff --git a/winsup/cygwin/mm/cygheap.cc b/winsup/cygwin/mm/cygheap.cc index 72861d8d7..6a20c159a 100644 --- a/winsup/cygwin/mm/cygheap.cc +++ b/winsup/cygwin/mm/cygheap.cc @@ -95,6 +95,8 @@ cygheap_fixup_in_child (bool execed) cygheap = (init_cygheap *) VirtualAlloc ((LPVOID) CYGHEAP_STORAGE_LOW, commit_size, MEM_COMMIT, PAGE_READWRITE); + if (dynamically_loaded && execed) + spawn_info->moreinfo->myself_pinfo = NULL; cygheap_max = child_proc_info->cygheap_max; child_copy (child_proc_info->parent, false, child_proc_info->silentfail (), "cygheap", cygheap, cygheap_max, NULL);