Bug 184073 - wrong signal delivery to multithreaded processes in Perl
Summary: wrong signal delivery to multithreaded processes in Perl
Status: Closed Works As Intended
Alias: None
Product: Base System
Classification: Unclassified
Component: threads (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-threads (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-19 07:40 UTC by Thomas Eckardt
Modified: 2015-05-15 16:16 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Eckardt 2013-11-19 07:40:00 UTC
using (any) threaded perl (5.10 ... 5.18) and any freebsd version 8.x (or gt) the following happens:

If a Perl script starts multiple threads (iThreads) - but at least one thread, all OS signals like 'kill -INT PID' are sent to the last started thread - NOT to the parent thread like expected.

freebsd versions below version 8 are not tested
Perl versions below 5.10 are not tested because of known Perl issue

Fix: 

No workaround.

The last started Perl child thread must send the received SIG to the parent thread. How ever, this makes it very hard to use signals for inter-thread communication and controlling
How-To-Repeat: start multiple iThreads in Perl (interactive) - try to terminate or interrupt the script via keyboard or from another process using 'kill -SIG PID' - this will not work.

I have a nice small perl script available to force/show the issue.
Tell me if you need it.
Comment 1 eischen 2013-11-19 08:40:34 UTC
There is no guarantee in POSIX that the main thread receives a
signal sent to the process if multiple threads (including the
main thread) have the signal unblocked.  The only way to
guarantee signal delivery to a specific thread is to send it
directly to the desired thread, have all threads other than the
desired thread mask the signal, or be blocked in sigwait{info}()
from the desired thread at the time of signal delivery.  You
are relying on behavior that is not specified by the standard.