From owner-freebsd-hackers@FreeBSD.ORG Tue May 2 00:52:04 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8BB9316A401 for ; Tue, 2 May 2006 00:52:04 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 229F143D45 for ; Tue, 2 May 2006 00:52:04 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.ntplx.net (8.13.6/8.13.6/NETPLEX) with ESMTP id k420q20f004072; Mon, 1 May 2006 20:52:02 -0400 (EDT) Date: Mon, 1 May 2006 20:52:02 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Alin-Adrian Anton In-Reply-To: <4456A5B3.2010809@spintech.ro> Message-ID: References: <4456A5B3.2010809@spintech.ro> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) Cc: freebsd-hackers@freebsd.org Subject: Re: which running thread gests the external signal X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 May 2006 00:52:04 -0000 On Tue, 2 May 2006, Alin-Adrian Anton wrote: > Hi Hackers, > > I'm working on a threaded daemon and I'm trying to make it sysadmin > friendly. For this, I'm working with external signals. > > I noticed different behaviour between BSD and Linux for this. When I > send an external SIGHUP (rehashing the config file) on BSD the thread > receiving the signal seems to be "random". POSIX states any thread that is in sigwait() (with the specified signal in the wait mask), or has the signal unmasked (in the threads signal mask) can receive the signal. If you want a certain thread to receive a process-wide signal, then the only sure way (POSIX) to do that is to block the signal in all the threads with the exception of the thread that is to receive the signal. > On Linux, if I remeber well, all > the threads get the signal, sooner or later.. (the signal handler gets > executed as many times as the number of running threads) Then Linux is wrong. I don't think that is the case any longer, but may have been with there older LinuxThreads model. > The tests I've done were done some time ago, this is why I must > appologise if I get the chance to mix the memories :|. > > So just in case anyone already knows (on BSD): which thread gets > stopped and moves execution to the signal handler function, when the signal > is sent by kill(1) to the pid of the daemon, which is the same for all the > threads? (sorry if dizzy speaking) See above. > And also, is there a way for delegating one special thread to handle > all the external signals? (on BSD) See above. > Thanks for the time guys. I would recommend you also visit http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html -- DE