Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2019-02-08 17:49:47 +0300
committerCorinna Vinschen <corinna@vinschen.de>2019-02-08 17:49:47 +0300
commit88605243a19bbc2b6b9be36b99f513140b972e38 (patch)
tree2e5e86c2252939accbe7d6a2b50524808d55b7aa /winsup/cygwin/pinfo.cc
parent6d6a623e7d8eb9e521bdbd73a7eafdd482678cea (diff)
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/pinfo.cc')
-rw-r--r--winsup/cygwin/pinfo.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index 445bd35b2..064299e0c 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -35,7 +35,7 @@ public:
pinfo_basic::pinfo_basic ()
{
- pid = dwProcessId = GetCurrentProcessId ();
+ dwProcessId = GetCurrentProcessId ();
PWCHAR pend = wcpncpy (progname, global_progname,
sizeof (progname) / sizeof (WCHAR) - 1);
*pend = L'\0';
@@ -57,15 +57,20 @@ pinfo::thisproc (HANDLE h)
procinfo = NULL;
DWORD flags = PID_IN_USE | PID_ACTIVE;
+ /* Forked process or process started from non-Cygwin parent needs a pid. */
if (!h)
{
cygheap->pid = create_cygwin_pid ();
flags |= PID_NEW;
}
+ /* spawnve'd process got pid in parent, cygheap->pid has been set in
+ child_info_spawn::handle_spawn. */
+ else if (h == INVALID_HANDLE_VALUE)
+ h = NULL;
init (cygheap->pid, flags, h);
procinfo->process_state |= PID_IN_USE;
- procinfo->dwProcessId = myself_initial.pid;
+ procinfo->dwProcessId = myself_initial.dwProcessId;
procinfo->sendsig = myself_initial.sendsig;
wcscpy (procinfo->progname, myself_initial.progname);
create_winpid_symlink ();