diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 6751d1888..fe3b93311 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2003-03-11 Corinna Vinschen + + * fhandler_socket.cc (fhandler_socket::dup): Don't call + fhandler_base::dup() but call DuplicateHandle directly instead to have + control over socket inheritence. + 2003-03-11 Corinna Vinschen * fhandler_socket.cc (fhandler_socket::dup): On NT systems avoid diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index c673df2af..7617bc23b 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -400,7 +400,20 @@ fhandler_socket::dup (fhandler_base *child) return get_io_handle () == (HANDLE) INVALID_SOCKET; } } - return fhandler_base::dup (child); + /* We don't call fhandler_base::dup here since that requires to + have winsock called from fhandler_base and it creates only + inheritable sockets which is wrong for winsock2. */ + HANDLE nh; + if (!DuplicateHandle (hMainProc, get_io_handle (), hMainProc, &nh, 0, + !winsock2_active, DUPLICATE_SAME_ACCESS)) + { + system_printf ("dup(%s) failed, handle %x, %E", + get_name (), get_io_handle ()); + __seterrno (); + return -1; + } + child->set_io_handle (nh); + return 0; } int __stdcall