delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/07/18/04:48:24

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Date: Wed, 18 Jul 2001 10:44:52 +0200
From: Corinna Vinschen <cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Linking to cygwin1.dll and msvcrt.dll ?
Message-ID: <20010718104452.C730@cygbert.vinschen.de>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <20010718000423 DOT A730 AT cygbert DOT vinschen DOT de> <Pine DOT SOL DOT 3 DOT 91 DOT 1010717155152 DOT 27797C-100000 AT cse DOT cygnus DOT com>
Mime-Version: 1.0
User-Agent: Mutt/1.2.5i
In-Reply-To: <Pine.SOL.3.91.1010717155152.27797C-100000@cse.cygnus.com>; from mdejong@cygnus.com on Tue, Jul 17, 2001 at 04:01:06PM -0700

On Tue, Jul 17, 2001 at 04:01:06PM -0700, Mo DeJong wrote:
> On Wed, 18 Jul 2001, Corinna Vinschen wrote:
> 
> > I'm somehow missing a
> > 
> >        CloseHandle ((HANDLE)code);
> > 
> > at this point which at least closes the handle to the thread. Otherwise
> > the following from MSDN is valid:
> > 
> >     The thread object remains in the system until the thread has
> >     terminated and all handles to it have been closed through a
> >     call to CloseHandle.
> > 
> > Corinna
> 
> That is interesting. The code variable is a local and the
> pointer is not saved. Would this call to CloseHandle()
> need to be done after a call to ExitThread()?

No. After CreateThread() the thread is up and running. The
handle returned by CreateThread() is just the handle for the
parent thread to have control over the child thread. If the
parent is not further interested in controlling the child
it simply closes the handle immediately and forgets about
the child thread:

  if ((thdl = CreateThread (...)) != NULL)
    CloseHandle (thdl):

This is only possible if the thread is not started in a suspended
state, of course. Otherwise the parent would need the handle to
resume the child.

If the parent thread never closes the thread handle, the thread
is similar to a zombie process which still waists system resources
until the process exits.

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