summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/spawn.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2000-10-26 10:13:41 +0000
committerCorinna Vinschen <corinna@vinschen.de>2000-10-26 10:13:41 +0000
commitdd4f0b2343d5b25894824635281fe88d85281824 (patch)
tree7583ace2f28016959576b515b2d5a555a28be0d3 /winsup/cygwin/spawn.cc
parent003303a43587449ced9b1aefa4188e3976b7bcfe (diff)
downloadcygnal-dd4f0b2343d5b25894824635281fe88d85281824.tar.gz
cygnal-dd4f0b2343d5b25894824635281fe88d85281824.tar.bz2
cygnal-dd4f0b2343d5b25894824635281fe88d85281824.zip
* dtable.cc (dtable::release): Check for socket. Change
cnt_need_fixup_before accordingly. (dtable::dup2): Ditto. (dtable::fixup_before_fork): New method. (dtable::fixup_before_exec): Ditto. * dtable.h (class dtable): Add member `cnt_need_fixup_before'. Add definition for methods `dec_need_fixup_before', `inc_need_fixup_before', `need_fixup_before', `fixup_before_exec' and `fixup_before_fork'. * fhandler.h (class fhandler_base): Slight rearrangements. Add definitions for methods `fixup_before_fork_exec'. (class fhandler_socket): Eliminate superfluous constructor. Add member `prot_info_ptr'. Add destructor. Add definitions for methods `dup', `fixup_before_fork_exec', `fixup_after_fork' and `fixup_after_exec'. * fork.cc (fork_parent): Care for file types which need a fixup before fork. Start child in suspended state then. * net.cc: New global variable `ws2_32_handle' and `wsadata'. (fdsock): Check for Winsock version. Call `set_socket_inheritance' only if Winsock version < 2.0. Care for `need_fixup' count in fdtab. (cygwin_socket): Eliminate call to `set_socket_inheritance'. (cygwin_accept): Ditto. (cygwin_rcmd): Ditto. (cygwin_rresvport): Ditto. (cygwin_rexec): Ditto. (socketpair): Ditto. (fhandler_socket::fhandler_socket): Set `need_fork_fixup'. Allocate space for the WSAPROTOCOL_INFOA struct used in fixup. (fhandler_socket::~fhandler_socket): New destructor. (fhandler_socket::fixup_before_fork_exec): New method. (fhandler_socket::fixup_after_fork): Ditto. (fhandler_socket::dup): Ditto. (wsock_init): New static function. (LoadDLLinitfunc (wsock32)): Rearranged. (LoadDLLinitfunc (ws2_32)): New function. (dummy_autoload): Add autoload statemants for `WSADuplicateSocketA' and `WSASocketA'. * spawn.cc (spawn_guts): Care for file types which need a fixup before exec. Start child in suspended state then.
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