summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>2018-06-05 12:40:21 +0200
committerCorinna Vinschen <corinna@vinschen.de>2019-02-05 10:20:16 +0100
commitfb3e8bd88b06be6b5e748b99aa50968bb46653a1 (patch)
treeaae03c2c18bcc5df877561bcbb3d415db798122f
parent99cd3df6ec471d6cbdea62fb14ebbe1e5eec8ef8 (diff)
downloadcygnal-fb3e8bd88b06be6b5e748b99aa50968bb46653a1.tar.gz
cygnal-fb3e8bd88b06be6b5e748b99aa50968bb46653a1.tar.bz2
cygnal-fb3e8bd88b06be6b5e748b99aa50968bb46653a1.zip
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.
-rw-r--r--winsup/cygwin/fork.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index c083f7a02..6f0036433 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -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);