Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Tue, 4 Jun 2002 12:44:58 -0400 (EDT) From: David E Euresti To: Subject: Re: Socket Handles duplicated twice after fork Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Hello, Corinna says: >The handles are only inherited if they are explicitly marked as >inheritable. The Cygwin code lives for a long time now under the >assumption that sockets aren't inheritable if they aren't >explicitely set to be inheritable (see net.cc, fdsock()). Hmmm. I think there's a wrong assumption here as you mentioned. MSDN says, http://support.microsoft.com/default.aspx?scid=kb;EN-US;q150523 Under Windows NT and Windows 2000, socket handles are inheritable by default. This feature is often used by a process that wants to spawn a child process and have the child process interact with the remote application on the other end of the connection. Windows 9x differs from Windows NT/Windows 2000 in the following manner: Socket handles are not inheritable when created. To ensure that a child process can obtain and use a socket handle created in the parent, the handle must be explicitly duplicated using the Win32 API DuplicateHandle. Set the bInheritHandle parameter of the API to TRUE. ... Therefore, on Win2k, you are letting them be inherited. So the probably the right solution is to always inherit, or to always duplicate, but never do both. Although I don't know maybe we want to inherit in Win2k and Duplicate in Win9x. (I hate this whole windows versions things) -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/