Subject: | POE::Component::Child needlessly shuts out perl subprocesses in P::W::R |
On line 182 of POE::Component::Child, subroutine got_run passes
'Program' argument to POE::Wheel::Run, which itself short-circuits to
run an external program as opposed to a coderef in a subprocess. The
attached diff will work either way, along with a documentation update.
Subject: | Child.pm.diff |
--- Child.pm.dist 2007-04-12 11:48:39.000000000 -0700
+++ Child.pm 2007-04-12 11:55:38.000000000 -0700
@@ -179,7 +179,8 @@
chdir $self->{$PKG}{chdir} if $self->{$PKG}{chdir};
my $wheel = POE::Wheel::Run->new(
- Program => $cmd,
+ Program => $cmd->[0],
+ ProgramArgs => [@{$cmd}[1..$#$cmd]],
StdioFilter => $self->{$PKG}{StdioFilter},
StdoutEvent => "stdout",
$conduit ? (Conduit => $conduit) : (StderrEvent => "stderr"),
@@ -370,6 +371,9 @@
$p = POE::Component::Child->new();
$p->run("ls", "-alF", "/tmp");
+
+ # or, alternatively:
+ $p->run(\&code, @args);
POE::Kernel->run();
@@ -426,7 +430,7 @@
=head2 run {array}
-This method requires an array indicating the command (and optional parameters) to run. The command and its parameters may also be passed as a single string. The method returns the I<id> of the wheel which is needed when running several commands simultasneously.
+This method requires an array indicating the command or CODE ref (and optional parameters) to run. An external command and its parameters may also be passed as a single string. CODE references must be passed as a list. The method returns the I<id> of the wheel which is needed when running several commands simultaneously.
Before calling this function, the caller may set stdio filter to a value of his choice. The example below shows the default used.