Subject: | IPC::Cmd run_forked issue with coderefs? |
Date: | Thu, 06 Jun 2013 00:01:13 -0400 |
To: | bug-ipc-cmd [...] rt.cpan.org |
From: | John Devitofranceschi <jdvf [...] optonline.net> |
Hi there...
I'm trying to figure out why this simple script does not work as expected:
================================
#!/usr/bin/perl
use IPC::Cmd 0.56 qw[run_forked];
sub runSub {
my $blah = "blahblah";
my $out= $_[0];
my $err= $_[1];
my $s = sub {
print "$blah\n";
print "$$: Hello $out\n";
warn "Boo!\n$err\n";
};
print "About to fork\n";
return run_forked($s);
}
print "current pid: $$\n";
my $retval= runSub("sailor", "eek!");
print "stdout:\n" . $retval->{"stdout"} . "\n";
print "stderr:\n" . $retval->{"stderr"} . "\n";
print "exit_code:\n" . $retval->{"exit_code"} . "\n";
======================================
Here is the output:
bash-3.2$ ./try.pl
current pid: 61243
About to fork
blahblah
61244: Hello sailor
Boo!
eek!
stdout:
stderr:
exit_code:
1
I expected:
bash-3.2$ ./try.pl
current pid: 61243
About to fork
stdout:
blahblah
61244: Hello sailor
stderr:
Boo!
eek!
exit_code:
1
It seems that stderr and stdout are not being populated and the output is just being sent to they tty.
or am I missing something?
jd
Message body not shown because it is not plain text.