Threads and signals

Jan Pechanec jp at devnull.cz
Thu Jan 3 16:03:30 PST 2008


On Thu, 3 Jan 2008, Kip Macy wrote:

>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.

	hi Kip, just to add, you can use pthread_mutex_lock() there from 
signal handlers since they are MT-safe but if you use it on the same mutex 
then you are still screwed. Well, it will probably work since be default 
mutexes on Solaris are of type PTHREAD_MUTEX_NORMAL but as you say - it 
depends on the platform. Locking the same mutex twice is plain wrong. By the 
way, the default type on FreeBSD is PTHREAD_MUTEX_ERRORCHECK.

	very probably the only reasonable way how to work with signals with 
threads is to mask all threads but one and to use sigwait(2) there. Butenhof 
has it all, as already said.

	J.

-- 
Jan Pechanec <jp (at) devnull (dot) cz>
http://www.devnull.cz


More information about the freebsd-threads mailing list