http://www.perlmonks.org?node_id=1020777


in reply to Perl 5.8.8 threads, clean exit

Well, "perldoc threads" makes specific mention of signals .. much like the OP's example. Why do you say, "don't use signals in threads?"

Replies are listed 'Best First'.
Re^2: Perl 5.8.8 threads, clean exit
by BrowserUk (Patriarch) on Feb 27, 2013 at 00:44 UTC

    Because I've read more than "a mention". Specifically:

    CAVEAT: The thread signalling capability provided by this module does not actually send signals via the OS. It emulates signals at the Perl-level such that signal handlers are called in the appropriate thread. For example, sending $thr->kill('STOP') does not actually suspend a thread (or the whole process), but does cause a $SIG{'STOP'} handler to be called in that thread (as illustrated above).

    As such, signals that would normally not be appropriate to use in the kill() command (e.g., kill('KILL', $$)) are okay to use with the ->kill() method (again, as illustrated above).

    Correspondingly, sending a signal to a thread does not disrupt the operation the thread is currently working on: The signal will be acted upon after the current operation has completed. For instance, if the thread is stuck on an I/O call, sending it a signal will not cause the I/O call to be interrupted such that the signal is acted up immediately.

    The 'signals' provided by threads are little more than an inappropriately named, elaborate polling mechanism. Ill-conceived; badly implemented; mostly useless.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.