我正在用我的 fcgi 脚本测试 Git::Repository。我既无法创建 git 对象,也无法使用该模块运行任何 git 命令。IPC::Open3::open3 失败并出现以下错误:
不是 /usr/local/lib/perl/5.10.1/FCGI.pm 第 125 行的 GLOB 引用
我在 FCGI::OPEN() 中添加了一个咯咯声,在 IPC::Open3::xopen() 中添加了一个警告,这就是我得到的:
mod_fcgid: stderr: IPC::Open3::xopen() called with args: GLOB(0xe92360) <&=5
mod_fcgid: stderr: IPC::Open3::xopen() called with args: GLOB(0xe92438) >&=9
mod_fcgid: stderr: IPC::Open3::xopen() called with args: GLOB(0xe92498) >&=12
mod_fcgid: stderr: FCGI::OPEN() called with args: FCGI::Stream=SCALAR(0x14e43f0) >&=12
mod_fcgid: stderr: at /usr/local/lib/perl/5.10.1/FCGI.pm line 125
mod_fcgid: stderr: \tFCGI::Stream::OPEN('FCGI::Stream=SCALAR(0x14e43f0)', '>&=12') called at /usr/share/perl/5.10/IPC/Open3.pm line 67
mod_fcgid: stderr: \tIPC::Open3::xopen('GLOB(0xe92498)', '>&=12') called at /usr/share/perl/5.10/IPC/Open3.pm line 162
mod_fcgid: stderr:
mod_fcgid: stderr: \tIPC::Open3::_open3('open3', 'MyModule', 'GLOB(0x1a56078)', 'GLOB(0x1906738)', 'GLOB(0x12f5430)' , '/usr/bin/git', '--version') called at /usr/share/perl/5.10/IPC/Open3.pm line 233
mod_fcgid: stderr: \tIPC::Open3::open3('GLOB(0x1a56078)', 'GLOB(0x1906738)', 'GLOB(0x12f5430)', '/usr/bin/git', '--version') called at /usr/local/lib/site_perl/MyModule.pm line 113
FCGI::OPEN() 仅在打开 STDERR 时调用。STDIN 和 STDOUT 没有达到 FCGI::OPEN()。我查看了 IPC::Open3 ,这是失败的地方:
if ($dad_rdr ne $dad_err) {
if ($dup_err) {
# I have to use a fileno here because in this one case
# I'm doing a dup but the filehandle might be a reference
# (from the special case above).
xopen \*STDERR, ">&" . xfileno($dad_err)
if fileno(STDERR) != xfileno($dad_err);
} else {
xclose $dad_err;
xopen \*STDERR, ">&=" . fileno $kid_err; # this is failing
}
} else {
xopen \*STDERR, ">&STDOUT" if fileno(STDERR) != fileno(STDOUT);
}
我可以用 IPC::Run::start 替换 open3 ,一切正常。但我真的很想了解这里的 STDERR 出了什么问题。是 FCGI.pm 或 Open3.pm 的错误还是我做错了什么?
我在 debian 挤压上运行带有 libapache2-mod-fcgid 1:2.3.6、libfcgi-perl 0.71-1 和 libcgi-fast-perl 5.10.1 的 apache 2.2.16。Perl 版本是 5.10.1。
如何重现:
use CGI::Fast;
use Symbol ();
use IPC::Open3 qw(open3);
while (my $cgi = new CGI::Fast) {
my $pid;
my $in = Symbol::gensym;
my $out = Symbol::gensym;
my $err = Symbol::gensym;
$pid = open3( $in, $out, $err, '/usr/bin/git', '--version');
}