[H-GEN] pthreads

Raymond Smith raymonds at uq.net.au
Wed Aug 25 23:45:00 EDT 1999


[ Humbug *General* list - semi-serious discussions about Humbug and
Unix-related topics. ]

On Thu, 26 Aug 1999, Allen Grace wrote:
> ...reading the manpage for pthread_mutex functions in Linux, one is
> explicitly warned not to call pthread_mutex_lock and
> pthread_mutex_unlock from a signal handler (risk of deadlock). 
> 
> 1. Is this only a problem for Linux, or is this a bad idea for all
> Unices?

It is a Bad Thing to do complicated stuff inside a signal handler.
 
> 2. What if I really want to do this? because (just for instance :) ) I
> might have a thread which modifies a structure, and then signals the
> parent process that the structure has been modified, so that it in turn
> can do things with it (including modify it).
> What else could one do?

You do not really want to do this. If you are using threads I would
suggest have a global variable you set in the signal handler and another
thread which periodically polls this variable and performs appropriate
actions.

Cheers,

Raymond

---
raymond at humbug.org.au              The early bird catches the worm, 
                                       but the second mouse eats the cheese


--
This is list (humbug) general handled by majordomo at lists.humbug.org.au .
Postings only from subscribed addresses of lists general or general-post.



More information about the General mailing list