IPC::Open3::xclose hotpatch
Andy Armstrong
andy at hexten.net
Thu May 15 19:59:07 UTC 2008
I've just found myself staring at the code in
TAP::Parser::Iterator::Process that hotpatches IPC::Open3 so that
STDIN isn't clobbered by xclose. The code looks like this:
# HOTPATCH {{{
my $xclose = \&IPC::Open3::xclose;
local $^W; # no warnings
local *IPC::Open3::xclose = sub {
my $fh = shift;
no strict 'refs';
return if ( fileno($fh) == fileno(STDIN) );
$xclose->($fh);
};
# }}}
(starts at T::P::I::P, line 119)
I'm wondering how / whether it works. The patch is localised; surely
by the time xclose is called the patch will have gone out of scope and
xclose will have reverted to its normal implementation?
Am I missing something?
--
Andy Armstrong, Hexten
More information about the tapx-dev
mailing list