Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (11)
As of 2014-08-20 14:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (116 votes), past polls