Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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 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> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; 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/