Date: Thu, 3 Jan 2008 14:38:52 -0800 From: "Kip Macy" <kip.macy@gmail.com> To: "Ivan Voras" <ivoras@freebsd.org> Cc: freebsd-threads@freebsd.org Subject: Re: Threads and signals Message-ID: <b1fa29170801031438m5d0c47cdtbef5363095570b11@mail.gmail.com> In-Reply-To: <fljin9$crb$1@ger.gmane.org> References: <fljin9$crb$1@ger.gmane.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Jan 3, 2008 1:05 PM, Ivan Voras <ivoras@freebsd.org> wrote: > Hi, > > How do threads interact with signals? In particular, if I have a "main" > process thread (the one started by main()) which generates items for a > mutex-protected queue which are consumed by a worker thread, and I need > to insert an item in the queue from the signal handler, am I correct > that doing pthread_mutex_lock() from the signal handler could deadlock > if the signal handler is executed by any of the threads (and the mutex > is non-recursive)? > > How is this solved in general? By recursive mutexes? > Very few functions are async signal safe. As a general rule you should avoid doing things from the signal handler itself. On some operating systems such as Solaris, most things will "just work". However, that can't be relied upon across platforms. -Kip
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?b1fa29170801031438m5d0c47cdtbef5363095570b11>