The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Process::KillTree - Kill process and all its descendants (children, grandchildren, ...)

VERSION

version 0.03

SYNOPSIS

 use Process::KillTree qw(kill_tree);

 my $pid = ...;
 kill_tree pid => $pid, signal => 'KILL';

DESCRIPTION

This module provides kill_tree().

SEE ALSO

Process::KillGroup

FUNCTIONS

kill_tree(%args) -> [status, msg, result, meta]

Kill process and all its descendants (children, grandchildren, ...).

To find out about child processes, Sys::Statistics::Linux::Processes is used on Linux. Croaks on other operating systems.

Returns the killed PIDs.

Arguments ('*' denotes required arguments):

  • action => code

    If specified, will call action instead of killing the processes.

    Code will be supplied $pids, an arrayref containing all the PIDs to kill.

  • pid => int

    Process ID to kill.

    Either pid or pids must be specified

  • pids => array

    Process IDs to kill.

    Either pid or pids must be specified

  • signal => str (default: "TERM")

    Signal to use, either numeric (e.g. 1), or string (e.g. KILL).

Return value:

Returns an enveloped result (an array). First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

AUTHOR

Steven Haryanto <stevenharyanto@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Steven Haryanto.

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