Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: how to kill a thread in windows

by Corion (Patriarch)
on Jun 23, 2006 at 15:18 UTC ( [id://557222]=note: print w/replies, xml ) Need Help??


in reply to how to kill a thread in windows

I don't think that's possible with the current Perls (5.8.x and 5.9.3 at this time of writing):

So maybe this feature is in the most recent version of the threads module, but I doubt it, as it will likely need support in the emulation layer for Perl. One thing I can think of would be to use the Windows API to suspend and/or kill your threads via their threads->tid, but this is very unclean, as Perl also keeps track of your threads and wraps them somewhat. If you really do kill them that way, be prepared for crashes at program exit time.

Update: Changed ->pid to ->tid as BrowserUk correctly notes below

Replies are listed 'Best First'.
Re^2: how to kill a thread in windows
by BrowserUk (Patriarch) on Jun 23, 2006 at 17:22 UTC
    One thing I can think of would be to use the Windows API to suspend and/or kill your threads via their threads->pid,

    I guess you meant threads->tid. Even so, that wouldn't work as the thread id it returns is a Perl-internal id, not anything the OS would recognise. However, the cpan version of the threads module does export threads->_handle which could be used in conjunction with Win32::API to Terminate a thread, but like you, I would strongly warn against designing code to use this.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^2: how to kill a thread in windows
by jdhedden (Deacon) on Jul 11, 2006 at 14:43 UTC
    The threads module has been greatly improved and enhanced as of late. Signalling between threads is now supported, even on Windows. With this feature, killing a thread is now supported.

    In addition, there is a new Thread::Suspend module that is based on new threads features. It works on Windows, as well.


    Remember: There's always one more bug.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://557222]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-25 23:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found