On 2001-06-14 15:06:56 +0000, Archie Cobbs wrote:
> > Michael Kapelevich wrote:
> > We are using Pth on freebsd.
> > We are getting segmantation fault when calling ptherad_mutex_lock in
> > signal handlers.
<snip/>
> > Is there a limitation on functions from pthreads in signal handlers?
> > Is there a way to reschedule the execution of the handlers to a more
> > steady point in the program ?
>
> In general you can do very little safely within a signal handler.
> For example, malloc() is not allowed because FreeBSD's malloc()
> is non reentrant. You can bet that pth does a lot of malloc's,
> so you should avoid calling such routines within signal handlers.
>
> Fortunately the answer is easy, use a PTH_EVENT_SIGNAL event or
> pth_sigwait() to be notified synchronously of the signal and these
> problems go away.
Indeed, this is not merely a Pth issue, but an issue with threads in
Unix in general. The basic rule is: "threads and signals don't mix".
Of course, if you really want to handle signals, the real rule is:
"signals should be handled by dedicated threads".
Shane
______________________________________________________________________
GNU Portable Threads (Pth) http://www.gnu.org/software/pth/
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager (Majordomo) [EMAIL PROTECTED]