Skip Menu |

This queue is for tickets about the Proc-Lite CPAN distribution.

Report information
The Basics
Id: 70298
Status: resolved
Priority: 0/
Queue: Proc-Lite

People
Owner: pravus [...] cpan.org
Requestors: knut-olav [...] hoven.ws
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.08
Fixed in: (no value)



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 );
On Tue Aug 16 11:28:12 2011, hovenko wrote: Show quoted text
> 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.
Thank-you for the feature suggestion. I incorporated a version of this into version 0.09 of Proc::Lite. I took a little bit different approach from the patch you provided using parent/child callbacks instead of a specific PID callback. The effect should be the same, however. I gave you credit for the suggestion in the Changes file. Thanks for the feedback.
Added parent/child callbacks to Proc::Lite 0.09 to allow for parent/child PID retrieval and pre-processing. Thank-you for the suggestion.