Subject: | Created a patch to pass in a pid handle |
I found it useful to get hold of the childs pid when using Proc::Hevy.
In the patch, I added a new property ("pid") to the constructor that
takes a subroutine reference. It will then call the subroutine with the
pid as argument.
Subject: | proc-hevy-pid.patch |
diff --git a/lib/Proc/Hevy.pm b/lib/Proc/Hevy.pm
index c42e843..ad01489 100644
--- a/lib/Proc/Hevy.pm
+++ b/lib/Proc/Hevy.pm
@@ -70,6 +70,9 @@ sub exec {
# parent
+ my $pidhandle = $args{'pid'} || undef;
+ &$pidhandle($pid) if $pidhandle;
+
my ( $select_w, $select_r ) = ( IO::Select->new, IO::Select->new );
my %handles = (
@@ -126,6 +129,21 @@ Proc::Hevy - A heavyweight module for running processes synchronously
}
{
+ my $pidhandle = sub {
+ my $pid = shift;
+ print STDERR "Child pid: $pid";
+ };
+
+ my $status = Proc::Hevy->exec(
+ command => 'cat',
+ stdin => "Useless use of cat\n",
+ stdout => \my $stdout,
+ stderr => \my $stderr,
+ pid => $pidhandle,
+ );
+ }
+
+ {
my @stdin = qw( foo bar baz );
my ( @stdout, @stderr );