Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Send signal to main thread

by menth0l (Monk)
on Sep 01, 2011 at 09:18 UTC ( [id://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.

Replies are listed 'Best First'.
Re: Send signal to main thread
by Corion (Patriarch) 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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-25 19:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found