GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Thread::Cancel(3) User Contributed Perl Documentation Thread::Cancel(3)

Thread::Cancel - Cancel (i.e., kill) threads

This document describes Thread::Cancel version 1.13

    use Thread::Cancel 'SIGUSR1';      # Set the cancellation signal
    use Thread::Cancel;                #  Defaults to 'KILL'

    $thr->cancel();                    # Cancel a thread
    threads->cancel();                 # Cancel all non-detached threads
    threads->cancel($thr, $tid, ...);  # Cancel multiple threads using
                                        #   objects or TIDs

This module adds cancellation capabilities for threads. Cancelled threads are terminated using "threads->exit()". The thread is then detached, and hence automatically cleaned up.

Threads that are suspended using Thread::Suspend do not need to be resumed in order to be cancelled.

It is possible for a thread to cancel itself.

This module must be imported prior to any threads being created.

Cancellation is accomplished via a signal handler which is used by all threads on which cancel operations are performed. The signal for this operation can be specified when this module is declared, and defaults to "SIGKILL". Consequently, the application and its threads must not specify some other handler for use with the cancel signal.

use Thread::Cancel;
Declares this module, and defaults to using "SIGKILL" for cancel operations.
use Thread::Cancel 'SIGUSR1';
use Thread::Cancel 'Signal' => 11;
Declares this module, and uses the specified signal for cancel operations. Signals may be specified by the same names or (positive) numbers as supported by kill().

$thr->cancel()
Cancels the threads.
threads->cancel()
Cancels all non-detached threads. This offers a clean way to exit a threaded application:

    # Terminate all threads and exit
    threads->cancel();
    exit(0);
    
threads->cancel($thr, $tid, ...)
Cancels the threads specified by their objects or TIDs (for non-detached threads).

Subject to the limitations of "THREAD SIGNALLING" in threads.

Cancelled threads are automatically detached, so do not try to "->join()" or "->detach()" a cancelled thread.

Detached threads can only be cancelled using their threads object:

    $thr->detach();
    $thr->cancel();
    # or
    threads->cancel($thr);

Threads that have finished execution are, for the most part, ignored by this module.

Perl 5.8.0 or later

threads 1.39 or later

Test::More 0.50 or later (for installation)

Thread::Cancel Discussion Forum on CPAN: <http://www.cpanforum.com/dist/Thread-Cancel>

threads, threads::shared

Jerry D. Hedden, <jdhedden AT cpan DOT org>

Copyright 2006 - 2009 Jerry D. Hedden. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

2010-12-24 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.