parallel: Fixed bug #41609: --compress fails

This commit is contained in:
Ole Tange 2014-02-16 18:57:57 +01:00
parent 7df7758404
commit be7ebcef23
5 changed files with 23 additions and 9 deletions

View file

@ -1,7 +1,7 @@
#!/usr/bin/env perl
# Copyright (C) 2007,2008,2009,2010,2011,2012,2013,2014 Ole Tange and Free Software
# Foundation, Inc.
# Copyright (C) 2007,2008,2009,2010,2011,2012,2013,2014 Ole Tange and
# Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -518,6 +518,7 @@ sub options_hash {
"tmpdir=s" => \$opt::tmpdir,
"tempdir=s" => \$opt::tmpdir,
"use-compress-program|compress-program=s" => \$opt::compress_program,
"use-decompress-program|decompress-program=s" => \$opt::decompress_program,
"compress" => \$opt::compress,
"tty" => \$opt::tty,
"T" => \$opt::retired,
@ -729,7 +730,7 @@ sub parse_options {
}
if($opt::compress_program) {
$opt::compress = 1;
$opt::decompress_program = $opt::compress_program." -dc";
$opt::decompress_program ||= $opt::compress_program." -dc";
}
if($opt::compress) {
my ($compress, $decompress) = find_compression_program();
@ -4065,11 +4066,15 @@ sub cattail {
$read = sysread(IN,$buf,1_000_000);
if($read) {
# Blocking print
syswrite(OUT,$buf);
while($buf) {
my $bytes_written = syswrite(OUT,$buf);
# syswrite may be interrupted by SIGHUP
substr($buf,0,$bytes_written) = "";
}
# Something printed: Wait less next time
$sleep /= 2;
} else {
if($Global::sighup) {
if(eof(IN) and $Global::sighup) {
# SIGHUP received: There will never be more to read => exit
exit;
}

View file

@ -1,6 +1,10 @@
#!/bin/bash
cat <<'EOF' | sed -e 's/;$/; /;s/$SERVER1/'$SERVER1'/;s/$SERVER2/'$SERVER2'/' | stdout parallel -j0 -k -L1
echo "bug #41609: --compress fails"
seq 12 | parallel --compress --compress-program bzip2 -k seq {} 1000000 | md5sum
seq 12 | parallel --compress -k seq {} 1000000 | md5sum
echo "### Test -I";
seq 1 10 | parallel -k 'seq 1 {} | parallel -k -I :: echo {} ::'

View file

@ -13,8 +13,9 @@ for i in $(seq 2 10); do
done
echo "### Test if --load blocks. Bug.";
seq 1 1000 | parallel -kj2 --load 300% --recend "\n" --spreadstdin gzip -1 | zcat | sort -n | md5sum
seq 1 1000 | parallel -kj0 --load 300% --recend "\n" --spreadstdin gzip -1 | zcat | sort -n | md5sum
seq 1 1000 | parallel -kj2 --load 300% --recend "\n" --spreadstdin gzip -1 | zcat | sort -n | md5sum
seq 1 1000 | parallel -kj0 --load 300% --recend "\n" --spreadstdin gzip -1 | zcat | sort -n | md5sum
seq 1 1000000 | parallel -kj0 --recend "\n" --spreadstdin gzip -1 | zcat | sort -n | md5sum
seq 1 1000000 | parallel -kj20 --recend "\n" --spreadstdin gzip -1 | zcat | sort -n | md5sum
echo "### Test reading load from PARALLEL"
seq 1 1000000 | parallel -kj0 --recend "\n" --spreadstdin gzip -1 | zcat | sort -n | md5sum
seq 1 1000000 | parallel -kj20 --recend "\n" --spreadstdin gzip -1 | zcat | sort -n | md5sum

View file

@ -1,3 +1,6 @@
bug #41609: --compress fails
24812dd0f24a26d08a780f988b9d5ad2 -
24812dd0f24a26d08a780f988b9d5ad2 -
### Test -I
1 1
2 1

View file

@ -24,5 +24,6 @@ c88e1757ddc619efd9ee507a7702b53c -
### Test if --load blocks. Bug.
53d025127ae99ab79e8502aae2d9bea6 -
53d025127ae99ab79e8502aae2d9bea6 -
### Test reading load from PARALLEL
8a7095c1c23bfadc311fe6b16d950582 -
8a7095c1c23bfadc311fe6b16d950582 -