fork: remove cygpid.N sharedmem on fork failure

When fork finally fails although both CreateProcess and creating the
"cygpid.N" shared memory section succeeded, we have to release that
shared memory section as well - before releasing the process handle.
Otherways we leave an orphan "cygpid.N" shared memory section, and any
subsequent cygwin process receiving the same PID fails to initialize.

* fork.cc (frok::parent): Call child.allow_remove in cleanup code.
This commit is contained in:
Michael Haubenwallner 2018-06-05 12:40:21 +02:00 committed by Corinna Vinschen
parent 99cd3df6ec
commit fb3e8bd88b
1 changed files with 4 additions and 1 deletions

View File

@ -499,13 +499,16 @@ frok::parent (volatile char * volatile stack_here)
/* Common cleanup code for failure cases */
cleanup:
/* release procinfo before hProcess in destructor */
child.allow_remove ();
if (fix_impersonation)
cygheap->user.reimpersonate ();
if (locked)
__malloc_unlock ();
/* Remember to de-allocate the fd table. */
if (hchild && !child.hProcess)
if (hchild && !child.hProcess) /* no child.procinfo */
ForceCloseHandle1 (hchild, childhProc);
if (forker_finished)
ForceCloseHandle (forker_finished);