diff --git a/src/parallel b/src/parallel index 33148272..7fc167d7 100755 --- a/src/parallel +++ b/src/parallel @@ -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; } diff --git a/testsuite/tests-to-run/parallel-local114.sh b/testsuite/tests-to-run/parallel-local114.sh index 26e14ff1..a077fd94 100755 --- a/testsuite/tests-to-run/parallel-local114.sh +++ b/testsuite/tests-to-run/parallel-local114.sh @@ -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 {} ::' diff --git a/testsuite/tests-to-run/parallel-local8.sh b/testsuite/tests-to-run/parallel-local8.sh index a43ec72b..1f1081c6 100644 --- a/testsuite/tests-to-run/parallel-local8.sh +++ b/testsuite/tests-to-run/parallel-local8.sh @@ -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 diff --git a/testsuite/wanted-results/parallel-local114 b/testsuite/wanted-results/parallel-local114 index 41aeeb58..3e51f6f5 100644 --- a/testsuite/wanted-results/parallel-local114 +++ b/testsuite/wanted-results/parallel-local114 @@ -1,3 +1,6 @@ +bug #41609: --compress fails +24812dd0f24a26d08a780f988b9d5ad2 - +24812dd0f24a26d08a780f988b9d5ad2 - ### Test -I 1 1 2 1 diff --git a/testsuite/wanted-results/parallel-local8 b/testsuite/wanted-results/parallel-local8 index 710882bd..d1028897 100644 --- a/testsuite/wanted-results/parallel-local8 +++ b/testsuite/wanted-results/parallel-local8 @@ -24,5 +24,6 @@ c88e1757ddc619efd9ee507a7702b53c - ### Test if --load blocks. Bug. 53d025127ae99ab79e8502aae2d9bea6 - 53d025127ae99ab79e8502aae2d9bea6 - +### Test reading load from PARALLEL 8a7095c1c23bfadc311fe6b16d950582 - 8a7095c1c23bfadc311fe6b16d950582 -