diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2019-02-08 15:49:47 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2019-02-08 15:49:47 +0100 |
commit | 88605243a19bbc2b6b9be36b99f513140b972e38 (patch) | |
tree | 2e5e86c2252939accbe7d6a2b50524808d55b7aa /winsup/cygwin/dcrt0.cc | |
parent | 6d6a623e7d8eb9e521bdbd73a7eafdd482678cea (diff) | |
download | newlib-88605243a19bbc2b6b9be36b99f513140b972e38.zip newlib-88605243a19bbc2b6b9be36b99f513140b972e38.tar.gz newlib-88605243a19bbc2b6b9be36b99f513140b972e38.tar.bz2 |
Cygwin: fix child getting another pid after spawnve
When calling spawnve, in contrast to execve, the parent has
to create the pid for the child. With the old technique
this was simply the Windows pid, but now we have to inform
the child about its new pid.
Add a cygpid member to class child_info_spawn. Set it in
child_info_spawn::worker, just prior to calling CreateProcess
rather than afterwards. Overwrite cygheap->pid in
child_info_spawn::handle_spawn before calling pinfo::thisproc.
Make sure pinfo::thisproc knows the pid is already set by
setting the handle argument to INVALID_HANDLE_VALUE.
Also set procinfo->dwProcessId to myself_initial.dwProcessId
instead of to myself_initial.pid for clarity.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin/dcrt0.cc')
-rw-r--r-- | winsup/cygwin/dcrt0.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 78506d4..11edcdf 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -652,11 +652,16 @@ child_info_spawn::handle_spawn () cygheap_fixup_in_child (true); memory_init (); } + + cygheap->pid = cygpid; + + /* Spawned process sets h to INVALID_HANDLE_VALUE to notify + pinfo::thisproc not to create another pid. */ if (!moreinfo->myself_pinfo || !DuplicateHandle (GetCurrentProcess (), moreinfo->myself_pinfo, GetCurrentProcess (), &h, 0, FALSE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE)) - h = NULL; + h = (type == _CH_SPAWN) ? INVALID_HANDLE_VALUE : NULL; /* Setup our write end of the process pipe. Clear the one in the structure. The destructor should never be called for this but, it can't hurt to be |