Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Jun 1998 10:25:48 +0200 (CEST)
From:      Marino Ladavac <lada@pc8811.gud.siemens.at>
To:        (Dag-Erling Coidan Sm\xrgrav) <smoergrd@oslo.geco-prakla.slb.com>
Cc:        hackers@FreeBSD.ORG
Subject:   RE: Signals in POSIX threads
Message-ID:  <XFMail.980622102548.lada@pc8811.gud.siemens.at>
In-Reply-To: <rx4yautd2gg.fsf@oslo.geco-prakla.slb.com>

next in thread | previous in thread | raw e-mail | index | archive | help

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.980622102548.lada>