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:
- understand this difference of behaviour
- avoid any more dependencies if possible
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?).