Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IPC::Open3::open3() doesn't work with perl 5.14.2 as with perl 5.10.1?

Tags:

perl

ipc

ipcopen3

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?).

like image 890
Cosimo Avatar asked Dec 27 '22 19:12

Cosimo


1 Answers

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.

like image 74
ikegami Avatar answered Jan 13 '23 16:01

ikegami