Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Send signal to main thread

by menth0l (Monk)
on Sep 01, 2011 at 09:18 UTC ( #923590=perlquestion: print w/ replies, xml ) Need Help??
menth0l has asked for the wisdom of the Perl Monks concerning the following question:

How can i send signal from child thread to main thread? I need to send signal to all threads including main. This doesn't work:
$_->kill('HUP') foreach threads->list;

I'm using ActiveState perl on Windows platform.

Comment on Send signal to main thread
Download Code
Replies are listed 'Best First'.
Re: Send signal to main thread
by Corion (Pope) on Sep 01, 2011 at 09:21 UTC

    Signals and threads don't mix well. Neither on Windows nor on Unix / POSIX threads. Don't do it.

    Update: cdarke points out that I'm mistaking the signals that threads implements for inter-thread signaling with the OS signals. As you are using the threads signals, ignore my comment.

      When using threads, catching a Ctrl-C to close up your program gracefully is a nightmare.

      While threads signals may work fine, catching signals from the terminal, such as Ctrl-C, still poses a difficult problem with no good solution (that I've encountered). There is no way to know which thread is going to receive the signal because the terminal sends the signal to the process group, not to a thread.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://923590]
Approved by salva
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2016-05-26 06:16 GMT
Find Nodes?
    Voting Booth?