From owner-freebsd-hackers@FreeBSD.ORG Thu Jan 8 10:21:20 2004 Return-Path: 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 C079D16A4CE for ; Thu, 8 Jan 2004 10:21:20 -0800 (PST) Received: from mwinf0502.wanadoo.fr (smtp5.wanadoo.fr [193.252.22.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id B0C9E43D3F for ; Thu, 8 Jan 2004 10:21:18 -0800 (PST) (envelope-from rmkml@wanadoo.fr) Received: from [192.168.1.2] (AVelizy-109-1-4-246.w80-15.abo.wanadoo.fr [80.15.82.246]) by mwinf0502.wanadoo.fr (SMTP Server) with ESMTP id D6FDFE80032C; Thu, 8 Jan 2004 19:21:16 +0100 (CET) Date: Thu, 8 Jan 2004 19:17:42 +0100 (CET) From: rmkml X-X-Sender: rmkml@hp.mgn.net To: Daniel Eischen In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-hackers@freebsd.org Subject: Re: problem with signal handling and threads (fbsd49R) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jan 2004 18:21:20 -0000 please can you give me an example of mask to SET BLOCK ou UNBLOCK in both threads (main and run) in order to make this sample code working ? thanks a lot. On Thu, 8 Jan 2004, Daniel Eischen wrote: > Date: Thu, 8 Jan 2004 08:48:34 -0500 (EST) > From: Daniel Eischen > To: rmkml > Cc: freebsd-hackers@freebsd.org > Subject: Re: problem with signal handling and threads (fbsd49R) > > On Thu, 8 Jan 2004, rmkml wrote: > > > Hi, > > > > I've got a problem with signal handling and threads. > > I've reproduced the problem in a simple code. > > Description of program: > > install a signal handler SIGINT. > > create a thread that do nothing except waiting. > > main thread use poll to wait forever [ poll(,,-1) ]. > > user has too crtl-C to interrupt poll > > after 5 ctrl-C, loop is over and main-thread signals sub-thread to > > stops. > > > > In fact, it appears not to work correctly: after one ctrl-C, user has to > > press ctrl-C twice before poll returns with errno=EINTR !! > > If the thread creation is removed from code, the expected behavior is > > seen : the program works fine. > > > > If I replace the poll by sigsuspend() the program works fine too. > > > > Is there something wrong with poll function ? > > No, it's your program. Why do you think the signal will > only be delivered to the main thread and not the other > (run) thread? If you want a particular thread to receive > a signal, then you had better set up signal masks for > all threads appropriately (or use sigwait()). > > > >