delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/06/04/13:24:35

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
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 18:23:49 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Socket Handles duplicated twice after fork
Message-ID: <20020604182349.L30892@cygbert.vinschen.de>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <Pine DOT GSO DOT 4 DOT 30L DOT 0206041052150 DOT 745-100000 AT scrubbing-bubbles DOT mit DOT edu>
Mime-Version: 1.0
In-Reply-To: <Pine.GSO.4.30L.0206041052150.745-100000@scrubbing-bubbles.mit.edu>
User-Agent: Mutt/1.3.22.1i

On Tue, Jun 04, 2002 at 10:59:00AM -0400, David E Euresti wrote:
> Ah the additional handles come from this.
> 
> fork call CreateProcess as follows
>   rc = CreateProcess (myself->progname, /* image to run */
> 		      myself->progname, /* what we send in arg0 */
> 		      sec_attribs,
> 		      sec_attribs,
> 		      TRUE,	  /* inherit handles from parent */
> 		      c_flags,
> 		      NULL,	  /* environment filled in later */
> 		      0,	  /* use current drive/directory */
> 		      &si,
> 		      &pi);
> 
> notice the inherit handles from parent,

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()).

This seems to be wrong, apparently.

> I don't know why it's written this way.  It would seem easier to just use
> the same Duplicated handle from the CreateProcess.  I'm thinking that
> maybe on Win9x it doesn't work the same (but I haven't even tested it)

You're right.  This code tries to eliminate a problem on 9x/Me
with sockets duplicated by DuplicateHandle() which results in
various annoying effects (see TechNet).  I'd never had written that
Winsock2 duplication code otherwise since we never had a problem
duplicating and inheriting a socket on NT.

Corinna

> Hope this helps.

Yes, it helps to rethink the situation.

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin AT cygwin DOT com
Red Hat, Inc.

--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019