Subject: | Capture::Tiny breaks under FCGI |
Hi,
thanks for Capture::Tiny! FCGI has a broken Tie::Handle XS
implementation. If you use Capture::Tiny in a FCGI driven webapp it dies:
Not a GLOB reference at
.../lib/perl5/i486-linux-gnu-thread-multi/FCGI.pm line 125.
The reason is the buggy Tie::Handle implementation from FCGI. See the
attached
test script to show the problems if STDIN is tied to such a buggy
Tie::Handle class. Maybe you can solve this within Capture::Tiny's
redirecting in the parent. That would be great!
Best Regards
Charly
Subject: | capture-tiny-tied.pl |
use strict;
use warnings;
use Capture::Tiny qw(capture);
# tie STDIN to a buggy Tie::Handle implementation like FCGI does
tie *STDIN, 'My::Handle';
my ( $stdin, $stdout ) = capture { system('date') };
exit;
# buggy Tie::Handle implementation, play wrong as FCGI does
{
package My::Handle;
use Carp;
require Tie::Handle;
@My::Handle::ISA = qw(Tie::Handle);
sub TIEHANDLE {
my $fh = \ do { no warnings; local *FH };
return bless $fh, shift;
}
#sub OPEN { @_ == 2 ? open( $_[0], $_[1] ) : open( $_[0], $_[1], $_[2] ) }
sub OPEN { Carp::confess "Buggy OPEN in package 'My::Handle', died"; }
sub CLOSE { close @_ }
sub FILENO { -1 }
}