From owner-freebsd-threads@FreeBSD.ORG Fri Jan 4 00:03:30 2008 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1841116A41A; Fri, 4 Jan 2008 00:03:30 +0000 (UTC) (envelope-from jp@devnull.cz) Received: from smtp1.vol.cz (smtp1.vol.cz [195.250.128.78]) by mx1.freebsd.org (Postfix) with ESMTP id CB7C113C469; Fri, 4 Jan 2008 00:03:29 +0000 (UTC) (envelope-from jp@devnull.cz) Received: from shark.devnull.cz (shark.devnull.cz [195.250.130.194]) by smtp1.vol.cz (Postfix) with ESMTP id 411B985E30; Fri, 4 Jan 2008 00:42:15 +0100 (CET) Date: Fri, 4 Jan 2008 00:42:15 +0100 (CET) From: Jan Pechanec To: Kip Macy In-Reply-To: Message-ID: <20080104003530.F93027@shark.devnull.cz> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: Ivan Voras , freebsd-threads@freebsd.org Subject: Re: Threads and signals X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Jan 2008 00:03:30 -0000 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 http://www.devnull.cz