site_archiver@lists.apple.com Delivered-To: Darwin-dev@lists.apple.com Le 12 mai 05, à 19:07, Matt Watson a écrit : On May 12, 2005, at 8:40 AM, Stéphane Letz wrote: Is there a workaround for that? This works fine for me on Tiger: #include <assert.h> #include <pthread.h> Thanks a lot. Actually is works also on Panther... mach_port_t machThread = pthread_mach_thread_np(fThread); thread_terminate(machThread); matt. Thanks. pthread_key_create(&__thread_destructor_key, __pthread_destructor); pthread_setspecific(__thread_destructor_key, this); pthread_key_create and pthread_setspecific return correctly 0. Then void __pthread_destructor(void* thread) { Thread* t; t = (Thread*) thread; t->Destructor(); } Thanks Stephane Letz _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... I am porting code that needs the PTHREAD_MUTEX_ERRORCHECK type of pthread_mutex. But it seems that PTHREAD_MUTEX_ERRORCHECK is not supported on Darwin. I get an EINVAL error when trying to use pthread_mutexattr_settype. int main (void) { pthread_mutexattr_t a; assert(!pthread_mutexattr_init(&a)); assert(!pthread_mutexattr_settype(&a, PTHREAD_MUTEX_ERRORCHECK)); return 0; } A second problem on the behaviour of pthread_cancel that is not correct. Is the use of explicit pthread_testcancel the way to go or can the following termination code be used safely? No, it can't. In previous versions of Mac OS X, pthread_testcancel() was the only cancellation point. Some code depended on this, so we had to preserve this behavior by default. If you define _APPLE_C_SOURCE when building your pthreads code on Tiger, you should get the new (proper) cancellation behavior. Now I have another problem (tested on Tiger), the following code is used to setup a destruction function in the thread before actually starting it: But after a pthread_cancel() has been called, the __pthread_destructor code is never called. Is there any known issue in using the pthread_key_create system? This email sent to site_archiver@lists.apple.com