summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/spawn.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/spawn.cc')
-rw-r--r--winsup/cygwin/spawn.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 2e0490db7..35aac9363 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -540,6 +540,14 @@ skip_arg_parsing:
if (mode != _P_OVERLAY)
flags |= CREATE_SUSPENDED;
+ /* Some file types (currently only sockets) need extra effort in the
+ parent after CreateProcess and before copying the datastructures
+ to the child. So we have to start the child in suspend state,
+ unfortunately, to avoid a race condition. */
+ if (fdtab.need_fixup_before ())
+ flags |= CREATE_SUSPENDED;
+
+
/* Build windows style environment list */
char *envblock;
if (real_path.iscygexec ())
@@ -656,6 +664,15 @@ skip_arg_parsing:
return -1;
}
+ /* Fixup the parent datastructure if needed and resume the child's
+ main thread. */
+ if (fdtab.need_fixup_before ())
+ {
+ fdtab.fixup_before_exec (pi.dwProcessId);
+ if (mode == _P_OVERLAY)
+ ResumeThread (pi.hThread);
+ }
+
if (mode == _P_OVERLAY)
cygpid = myself->pid;
else