In one of our modules, we check if a given binary (varnishd
) exists, and if so, we run additional tests.
To perform the check, we're using IPC::Open3
, like this (example stripped down for clarity):
perl -MIPC::Open3 -le '
my $binary = "varnishd";
my $pid = IPC::Open3::open3(my($in, $out), undef, $binary, "-V");
waitpid $pid, 0; print $?'
Under Debian Squeeze, or Ubuntu Natty, with perl 5.10.1, if varnishd
is not found on the system, this prints 65280
for me.
If you change the $binary
to perl
, then is (correctly) prints 0
.
However, with Ubuntu Precise and perl 5.14.2, this doesn't work in the same way anymore, and produces the following:
$ perl -MIPC::Open3 -le '
my $binary = "varnishd";
my $pid = IPC::Open3::open3(my($in, $out), undef, $binary, "-V");
waitpid $pid, 0; print $?'
open3: exec of varnishd -V failed at -e line1
When I change the $binary
to something that exists, for example perl
, then it works correctly and prints 0
.
$ perl -MIPC::Open3 -le '
my $binary = "perl";
my $pid = IPC::Open3::open3(my($in, $out), undef, $binary, "-V");
waitpid $pid, 0; print $?'
0
Reading other questions and answers, it looks like I want to look into IPC::Run, but I would like to actually:
EDIT: forgot to mention that this stuff is running under a chroot environment, both Squeeze and Precise systems, if that's at all relevant (/dev
filesystem differences, for example?).
You are noticing a bug fix.
In what you call the 5.10.1 version, open3
reported that the program ran and exited with code 255. Neither of those are true.
In what you call the 5.14.2 version, open3
throws an exception as it has always been documented to do and as it always has done for some other problems. You may catch failures to launch the child using with eval BLOCK
if so desired.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With