delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/07/17/20:40:53

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: Tue, 17 Jul 2001 16:01:06 -0700 (PDT)
From: Mo DeJong <mdejong AT cygnus DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Linking to cygwin1.dll and msvcrt.dll ?
In-Reply-To: <20010718000423.A730@cygbert.vinschen.de>
Message-ID: <Pine.SOL.3.91.1010717155152.27797C-100000@cse.cygnus.com>
MIME-Version: 1.0

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

I guess I am not even sure why a call to _beginthreadex
is being made here instead of calling CreateThread.
The cvs log talks about a memory leak, perhaps this is
the leak Corinna has identified.

cheers
Mo

P.S.
Here is the patch I am currently playing with. This
is from the CVS version of Tcl at sourceforge.

Index: win/tclWinThrd.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinThrd.c,v
retrieving revision 1.12
diff -u -r1.12 tclWinThrd.c
--- win/tclWinThrd.c	2001/07/16 23:30:16	1.12
+++ win/tclWinThrd.c	2001/07/17 22:55:14
@@ -135,8 +135,15 @@
 
     EnterCriticalSection(&joinLock);
 
-    code = _beginthreadex(NULL, (unsigned) stackSize, proc, clientData, 0,
-	(unsigned *)idPtr);
+#ifdef __CYGWIN__
+    code = (unsigned long) CreateThread(NULL, (unsigned) stackSize,
+        (LPTHREAD_START_ROUTINE) proc, (LPVOID) clientData,
+        (DWORD) 0, (DWORD *)idPtr);
+#else
+    code = _beginthreadex(NULL, (unsigned) stackSize,
+        proc, (void *) clientData,
+        (unsigned) 0, (unsigned *)idPtr);
+#endif /* CYGWIN */
 
     if (code == 0) {
         LeaveCriticalSection(&joinLock);
@@ -202,7 +209,11 @@
     TclSignalExitThread (Tcl_GetCurrentThread (), status);
     LeaveCriticalSection(&joinLock);
 
+#ifdef __CYGWIN__
+    ExitThread((DWORD)status);
+#else
     _endthreadex((DWORD)status);
+#endif /* __CYGWIN__ */
 }
 
 

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