Date: Thu, 8 Jan 2004 08:48:34 -0500 (EST) From: Daniel Eischen <eischen@vigrid.com> To: rmkml <rmkml@wanadoo.fr> Cc: freebsd-hackers@freebsd.org Subject: Re: problem with signal handling and threads (fbsd49R) Message-ID: <Pine.GSO.4.10.10401080845330.13804-100000@pcnet5.pcnet.com> In-Reply-To: <Pine.LNX.4.58.0401081150010.12240@hp.mgn.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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()).
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.10.10401080845330.13804-100000>