aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/fhandler_socket.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2006-01-23 15:10:57 +0000
committerCorinna Vinschen <corinna@vinschen.de>2006-01-23 15:10:57 +0000
commit543c43d84de8ba2bf09cc733cde4e332441184a6 (patch)
tree4666792fe47dd4433b4142d9546a8396dae449b1 /winsup/cygwin/fhandler_socket.cc
parentcfd86743ff775e2af002f116f9df71db543ea42e (diff)
downloadnewlib-543c43d84de8ba2bf09cc733cde4e332441184a6.zip
newlib-543c43d84de8ba2bf09cc733cde4e332441184a6.tar.gz
newlib-543c43d84de8ba2bf09cc733cde4e332441184a6.tar.bz2
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Reset
inheritance for duplicated socket.
Diffstat (limited to 'winsup/cygwin/fhandler_socket.cc')
-rw-r--r--winsup/cygwin/fhandler_socket.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index a4ca44f..2405471 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -424,7 +424,16 @@ fhandler_socket::fixup_after_fork (HANDLE parent)
}
else
{
- debug_printf ("WSASocket went fine new_sock %p, old_sock %p", new_sock, get_io_handle ());
+ debug_printf ("WSASocket went fine new_sock %p, old_sock %p", new_sock, get_socket ());
+
+ /* Go figure! Even though the original socket was not inheritable,
+ the duplicated socket is inheritable again. This can lead to all
+ sorts of trouble, apparently. Note that there's no way to prevent
+ this on 9x, not even by trying to reset socket inheritance using
+ DuplicateHandle and closing the original socket. */
+ if (wincap.has_set_handle_information ())
+ SetHandleInformation ((HANDLE) new_sock, HANDLE_FLAG_INHERIT, 0);
+
set_io_handle ((HANDLE) new_sock);
}
}