pthread_mutex_unlock not permitted in signal handler?
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Thoughts? thanks -ethan _______________________________________________ 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... In trying to find a workaround to my previous message (destructors not being called on pthread_cancel), In this case, I have a set of pthread_cleanup statements which trigger a call to pthread_mutex_unlock on cancellation. The trick is that on Tiger (Darwin 8.11.1), since I can't cancel out of a read()/sleep()/etc., I use a pthread_kill() to send a signal, and then the signal handler does pthread_testcancel(). Ugly as it is, this much has been working for a while now. However, when I try to call pthread_mutex_unlock from the cleanup function that results from the eventual pthread_testcancel, it returns an error "Operation not permitted". Is it *at all possible* to unlock a mutex following the interruption of a thread on Tiger? (I haven't tried this on Leopard yet -- since I don't need to do the signal hack there, hopefully this is moot) Basically, I'm reading from a socket, and need a way to kill the thread if there's no response. But I also need to maintain a lock on the socket while I'm waiting for a response so other tasks don't try to send their own queries. I'm polling relatively frequently, so I don't want to have to take the lock, launch a new thread, and monitor the other thread every time. (this is a real-time task with a hardware device) This email sent to site_archiver@lists.apple.com
participants (1)
-
Ethan Tira-Thompson