From owner-freebsd-hackers Mon Jun 22 01:26:05 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id BAA17779 for freebsd-hackers-outgoing; Mon, 22 Jun 1998 01:26:05 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from zwei (zwei.siemens.at [193.81.246.12]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id BAA17736 for ; Mon, 22 Jun 1998 01:25:56 -0700 (PDT) (envelope-from lada@pc8811.gud.siemens.at) Received: from pc8811.gud.siemens.at (root@[10.1.140.1]) by zwei with ESMTP id KAA17858; Mon, 22 Jun 1998 10:25:22 +0200 (MET DST) Received: from pc8811.gud.siemens.at (pc8811.gud.siemens.at [195.3.22.159]) by pc8811.gud.siemens.at (8.8.8/8.8.8) with ESMTP id KAA11942; Mon, 22 Jun 1998 10:25:48 +0200 (CEST) (envelope-from lada@pc8811.gud.siemens.at) Message-ID: X-Mailer: XFMail 1.2 [p0] on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: Date: Mon, 22 Jun 1998 10:25:48 +0200 (CEST) Organization: Siemens Austria AG From: Marino Ladavac To: (Dag-Erling Coidan Sm\xrgrav) Subject: RE: Signals in POSIX threads Cc: hackers@FreeBSD.ORG Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 19-Jun-98 Dag-Erling Coidan Sm\xrgrav wrote: > This is not strictly FreeBSD-related, but I thought I'd ask here since > many of you are probably working with pthreads at some level. > > Is there any way to force all (or specific) signals sent to a process > to be sent to a particular thread? The behaviour I'm seeing nową is > that the signal is going to a seemingly random thread˛. Wether the > signal handler is being installed before or after the threads are > started doesn't seem to make a difference. Unless I am grossly mistaken, the pthreads explicitly specifies that all signals arriving asynchronously (i.e. via kill() and similar methods) should be passed to one of the threads not masking that particular signal. That was Draft 7, and I believe that the later drafts have removed the thread specific signal masks. This means that you cannot specify the thread which should receive a signal. But see below--there might be a way out: However, the thread that does sigwait() on that particular signal will get it, and nobody else (unless you have another thread sigwait()ing on that particular signal in which case you are treading the undefined ways. A nasty issue with sigwait() is that it accepts waits only for a subset of signals which always have to be asynchronous--it will not wait on SIGFPE, SIGSEGV and the others which could be delivered through the fault in your program. These signals will always be delivered to the thread that caused them (or the currently running thread in case that these signals have been generated via kill()). > > I asked a colleague at Geco about it, and his answer was "Whatever you > want to do, find a way to do it that doesn't involve signals." Not > very helpful :) I would tend to agree with your colleague: you would be well advised to use some other method of IPC rather than signals. If you wish to wait on SIGCHILD, however, the sigwait() does excellent job of it. /Marino To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message