[Pcsclite-cvs-commit] PCSC/src thread_unix.c,1.15,1.16

rousseau@haydn.debian.org rousseau@haydn.debian.org


Update of /cvsroot/pcsclite/PCSC/src
In directory haydn:/tmp/cvs-serv29552

Modified Files:
	thread_unix.c 
Log Message:
SYS_ThreadCreate(): set the thread state: joinable or detached
default is joinable


Index: thread_unix.c
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/thread_unix.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- thread_unix.c	17 Jun 2004 06:44:01 -0000	1.15
+++ thread_unix.c	2 Aug 2004 21:51:38 -0000	1.16
@@ -40,10 +40,19 @@
 	return pthread_mutex_unlock(mMutex);
 }
 
-int SYS_ThreadCreate(PCSCLITE_THREAD_T * pthThread, LPVOID pthAttr,
+int SYS_ThreadCreate(PCSCLITE_THREAD_T * pthThread, int attributes,
 	PCSCLITE_THREAD_FUNCTION(pvFunction), LPVOID pvArg)
 {
-	if (0 == pthread_create(pthThread, NULL, pvFunction, pvArg))
+	pthread_attr_t attr;
+	
+	if (0 != pthread_attr_init(&attr))
+		return FALSE;
+	
+	if (0 != pthread_attr_setdetachstate(&attr,
+		attributes & THREAD_ATTR_DETACHED ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE))
+		return FALSE;
+	
+	if (0 == pthread_create(pthThread, &attr, pvFunction, pvArg))
 		return TRUE;
 	else
 		return FALSE;