From 4082c240154890a0ad71ca21c9293f7e1482b5ef Mon Sep 17 00:00:00 2001 From: corinna Date: Mon, 23 Jan 2006 15:10:57 +0000 Subject: [PATCH] * fhandler_socket.cc (fhandler_socket::fixup_after_fork): Reset inheritance for duplicated socket. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/fhandler_socket.cc | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 9bc68e2af2..cae5ee6af4 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2006-01-23 Corinna Vinschen + + * fhandler_socket.cc (fhandler_socket::fixup_after_fork): Reset + inheritance for duplicated socket. + 2006-01-20 Christopher Faylor * include/cygwin/version.h: Bump API minor number to 151. diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index a4ca44faf6..2405471fec 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); } } -- 2.11.0