Subject: | Archive::Extract will hang if stdin is a pipe [+PATCH] |
The introduction of the have_old_bunzip2 method in 0.24 also introduces
a nasty bug -- have_old_bunzip2 depends upon stdin being a terminal, so
that when it bunzip2 immediately exists when called as 'bunzip2
--version'. If stdin is not a terminal (i.e., a pipe), then bunzip2
will block waiting to read stdin. An easy way to test this is to run
the tests with stdin set to a pipe:
$ sleep 100| make test
PERL_DL_NONLAZY=1
/hub/share/apps/BuildTools/Linux/glibc-2.3.4/x86_64/perl/perl-5.8.8-tmw-025/bin/perl
"-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib',
'blib/arch')" t/*.t
t/01_Archive-Extract....ok 1/0
After 100 seconds, it will continue.
This ends up applying to EVERY program that uses Archive::Extract -- if
have_old_bunzip2 is called, it will try to read stdin. This is
disastrous if you've set $Archive::Extract::PREFER_BIN and pass it a
tar.bz2 file.
Thankfully, the fix is trivial:
482c482
< scalar run( command => [$self->bin_bunzip2, '--version'],
---
Show quoted text
> scalar run( command => [$self->bin_bunzip2, '--version',
'there-is-no-such-file-at-all'],
Alternately, you could dup STDIN and then reopen it to the path from
File::Spec->devnull, and then restore STDIN. I thought the above was
simpler.