niceload now propagates exit status correctly. Passes testsuite.

This commit is contained in:
Ole Tange 2012-01-08 19:52:00 +01:00
parent 92d7c462e7
commit 7bd02750a5
15 changed files with 68 additions and 59 deletions

View file

@ -192,14 +192,23 @@ available for download at: http://ftp.gnu.org/gnu/parallel/
New in this release:
* Blog post on using GNU Parallel to speed up BLAST queries:
http://blog.mckuhn.de/2012/01/embarrassingly-parallel-blast-search.html
* niceload now propagates exit status correctly. Passes testsuite.
* Show your support for GNU Parallel. For 20 EUR incl world wide
shipping get a GNU Parallel T-shirt+mug+pen+100 postcards. Email
your shirt size and address for details to
parallel-support@tange.dk.
* --header uses the first input line as column names and you can then
use {colname} as a replacement string in the command.
* --resume resumes from the last unfinished job.
* Options -g -B -T -U -W -Y are retired as warned 6 months ago.
* Blog post on using GNU Parallel to speed up BLAST queries:
http://blog.mckuhn.de/2012/01/embarrassingly-parallel-blast-search.html
* Video showing Wake-on-LAN with GNU Parallel.
https://www.youtube.com/watch?v=0mB-yIyKFLQ

View file

@ -84,6 +84,7 @@ while($process->is_alive()) {
}
}
exit($::exitstatus);
sub get_options_from_array {
# Run GetOptions on @array
@ -296,18 +297,21 @@ sub start {
} else {
system("@{$self->{'command'}}");
}
::debug("Child exit\n");
exit;
$::exitstatus = $? >> 8;
$::exitsignal = $? & 127;
::debug("Child exit $::exitstatus\n");
exit($::exitstatus);
}
}
use POSIX ":sys_wait_h";
sub REAPER {
my $stiff;
while (($stiff = waitpid(-1, &WNOHANG)) > 0) {
# do something with $stiff if you want
$::exitstatus = $? >> 8;
$::exitsignal = $? & 127;
}
$SIG{CHLD} = \&REAPER; # install *after* calling waitpid
}
@ -640,3 +644,5 @@ sub io_status_linux {
my $io = ::max(@iostat);
return $io/10;
}
$::exitsignal = $::exitstatus = 0; # Dummy

View file

@ -437,7 +437,7 @@ sub options_hash {
"trc=s" => \@::opt_trc,
"transfer" => \$::opt_transfer,
"cleanup" => \$::opt_cleanup,
"basefile|bf" => \@::opt_basefile,
"basefile|bf=s" => \@::opt_basefile,
"B=s" => \$::opt_retired,
"workdir|wd=s" => \$::opt_workdir,
"W=s" => \$::opt_retired,
@ -518,7 +518,7 @@ sub get_options_from_array {
@::ARGV = @{$array_ref};
}
my @retval = GetOptions(options_hash());
if(not $this_is_ARGV) {
if(not $this_is_ARGV) {
@{$array_ref} = @::ARGV;
@::ARGV = @save_argv;
}

View file

@ -0,0 +1,5 @@
#!/bin/bash
echo '### Test niceload exit code'
niceload "perl -e 'exit(3)'" ; echo $? eq 3
niceload "perl -e 'exit(0)'" ; echo $? eq 0

View file

@ -11,16 +11,16 @@ ls | parallel ls | sort
ls | parallel echo ls | sort
ls | parallel -j 1 echo ls | sort
find -type f | parallel diff {} a/foo ">"{}.diff | sort
ls | parallel -vg "ls {}|wc;echo {}" | sort
ls | parallel -v --group "ls {}|wc;echo {}" | sort
echo '### Check that we can have more input than max procs (-j 0)'
perl -e 'print map {"more_than_5000-$_\n" } (4000..9999)' | parallel -vj 0 touch | sort | tail
perl -e 'print map {"more_than_5000-$_\n" } (4000..9900)' | parallel -j 0 rm | sort
ls | parallel -j500 'sleep 1; find {} -type f | perl -ne "END{print $..\" {}\n\"}"' | sort
ls | parallel -gj500 'sleep 1; find {} -type f | perl -ne "END{print $..\" {}\n\"}"' | sort
find . -type f | parallel -g "perl -ne '/^\\S+\\s+\\S+$/ and print \$ARGV,\"\\n\"'" | sort
find . -type f | parallel -vg "perl -ne '/^\\S+\\s+\\S+$/ and print \$ARGV,\"\\n\"'" | sort
find . -type f | parallel -qg perl -ne '/^\S+\s+\S+$/ and print $ARGV,"\n"' | sort
find . -type f | parallel -qvg perl -ne '/^\S+\s+\S+$/ and print $ARGV,"\n"' | sort
ls | parallel --group -j500 'sleep 1; find {} -type f | perl -ne "END{print $..\" {}\n\"}"' | sort
find . -type f | parallel --group "perl -ne '/^\\S+\\s+\\S+$/ and print \$ARGV,\"\\n\"'" | sort
find . -type f | parallel -v --group "perl -ne '/^\\S+\\s+\\S+$/ and print \$ARGV,\"\\n\"'" | sort
find . -type f | parallel -q --group perl -ne '/^\S+\s+\S+$/ and print $ARGV,"\n"' | sort
find . -type f | parallel -qv --group perl -ne '/^\S+\s+\S+$/ and print $ARGV,"\n"' | sort
cd ..
rm -rf tmp

View file

@ -20,25 +20,25 @@ echo '### Test exit val - false';
echo '### Test --halt-on-error 0';
(echo "sleep 1;true"; echo "sleep 2;false";echo "sleep 3;true") | parallel -j10 --halt-on-error 0;
echo $?;
(echo "sleep 1;true"; echo "sleep 2;false";echo "sleep 3;true";echo "sleep 4; non_exist") | parallel -j10 -H0;
(echo "sleep 1;true"; echo "sleep 2;false";echo "sleep 3;true";echo "sleep 4; non_exist") | parallel -j10 --halt 0;
echo $?
echo '### Test --halt-on-error 1';
(echo "sleep 1;true"; echo "sleep 2;false";echo "sleep 3;true") | parallel -j10 --halt-on-error 1;
echo $?;
(echo "sleep 1;true"; echo "sleep 2;false";echo "sleep 3;true";echo "sleep 4; non_exist") | parallel -j10 -H1;
(echo "sleep 1;true"; echo "sleep 2;false";echo "sleep 3;true";echo "sleep 4; non_exist") | parallel -j10 --halt 1;
echo $?
echo '### Test --halt-on-error 2';
(echo "sleep 1;true"; echo "sleep 2;false";echo "sleep 3;true") | parallel -j10 --halt-on-error 2;
echo $?;
(echo "sleep 1;true"; echo "sleep 2;false";echo "sleep 3;true";echo "sleep 4; non_exist") | parallel -j10 -H2;
(echo "sleep 1;true"; echo "sleep 2;false";echo "sleep 3;true";echo "sleep 4; non_exist") | parallel -j10 --halt 2;
echo $?
echo '### Test last dying print --halt-on-error';
(seq 0 8;echo 0; echo 9) | parallel -j10 -kqH1 perl -e 'sleep $ARGV[0];print STDERR @ARGV,"\n"; exit shift';
(seq 0 8;echo 0; echo 9) | parallel -j10 -kq --halt 1 perl -e 'sleep $ARGV[0];print STDERR @ARGV,"\n"; exit shift';
echo $?;
(seq 0 8;echo 0; echo 9) | parallel -j10 -kqH2 perl -e 'sleep $ARGV[0];print STDERR @ARGV,"\n"; exit shift';
(seq 0 8;echo 0; echo 9) | parallel -j10 -kq --halt 2 perl -e 'sleep $ARGV[0];print STDERR @ARGV,"\n"; exit shift';
echo $?
echo '### Test slow arguments generation - https://savannah.gnu.org/bugs/?32834';

View file

@ -102,7 +102,7 @@ echo 3 | xargs -P 1 -n 1 -a files cat -
echo 'parallel Expect: 3 1 via psedotty 2'
cat >/tmp/parallel-script-for-script <<EOF
#!/bin/bash
echo 3 | parallel -T -k -P 1 -n 1 -a files cat -
echo 3 | parallel --tty -k -P 1 -n 1 -a files cat -
EOF
chmod 755 /tmp/parallel-script-for-script
echo via pseudotty | script -q -f -c /tmp/parallel-script-for-script /dev/null
@ -113,7 +113,7 @@ echo 3 | xargs -I {} -P 1 -n 1 -a files cat {} -
echo 'parallel Expect: 1 3 2 via pseudotty'
cat >/tmp/parallel-script-for-script2 <<EOF
#!/bin/bash
echo 3 | parallel -T -k -I {} -P 1 -n 1 -a files cat {} -
echo 3 | parallel --tty -k -I {} -P 1 -n 1 -a files cat {} -
EOF
chmod 755 /tmp/parallel-script-for-script2
echo via pseudotty | script -q -f -c /tmp/parallel-script-for-script2 /dev/null

View file

@ -20,9 +20,9 @@ rm -rf /tmp/test-of-{.}-parallel/subdir
find -type f | parallel -k diff {} a/foo ">"{.}.diff
ls | parallel -kvg "ls {}|wc;echo {}"
ls | parallel -kv --group "ls {}|wc;echo {}"
ls | parallel -kj500 'sleep 1; ls {} | perl -ne "END{print $..\" {}\n\"}"'
ls | parallel -kgj500 'sleep 1; ls {} | perl -ne "END{print $..\" {}\n\"}"'
ls | parallel -kj500 --group 'sleep 1; ls {} | perl -ne "END{print $..\" {}\n\"}"'
mkdir 1-col 2-col
ls | parallel -kv touch -- {.}/abc-{.}-{} 2>&1
ls | parallel -kv rm -- {.}/abc-{.}-{} 2>&1

View file

@ -15,7 +15,7 @@ echo '### Test --basefile + --cleanup + permissions'
echo echo script1 run '"$@"' > script1
echo echo script2 run '"$@"' > script2
chmod 755 script1 script2
seq 1 5 | parallel -kS $SSHLOGIN1 --cleanup -B script1 --basefile script2 "./script1 {};./script2 {}"
seq 1 5 | parallel -kS $SSHLOGIN1 --cleanup --bf script1 --basefile script2 "./script1 {};./script2 {}"
echo good if no file
stdout ssh $SSHLOGIN1 ls 'script1' || echo OK
stdout ssh $SSHLOGIN1 ls 'script2' || echo OK
@ -26,7 +26,7 @@ chmod 755 my_script
rm -f parallel_*.test parallel_*.out
seq 1 13 | parallel echo {} '>' parallel_{}.test
ls parallel_*.test | parallel -j+0 --trc {.}.out -B my_script \
ls parallel_*.test | parallel -j+0 --trc {.}.out --bf my_script \
-S $SSHLOGIN1,$SSHLOGIN2,: "./my_script {} > {.}.out"
cat parallel_*.test parallel_*.out

View file

@ -13,7 +13,7 @@ parallel --argsep .--- -kv .--- 'echo a' 'echo b'
echo '### Test stdin goes to first command only ("-" as argument)'
cat >/tmp/parallel-script-for-script <<EOF
#!/bin/bash
echo via first cat |parallel -T -kv cat ::: - -
echo via first cat |parallel --tty -kv cat ::: - -
EOF
chmod 755 /tmp/parallel-script-for-script
echo via pseudotty | script -q -f -c /tmp/parallel-script-for-script /dev/null
@ -21,7 +21,7 @@ sleep 2
echo '### Test stdin goes to first command only ("cat" as argument)'
cat >/tmp/parallel-script-for-script2 <<EOF
#!/bin/bash
echo no output |parallel -T -kv ::: 'echo a' 'cat'
echo no output |parallel --tty -kv ::: 'echo a' 'cat'
EOF
chmod 755 /tmp/parallel-script-for-script2
echo via pseudotty | script -q -f -c /tmp/parallel-script-for-script2 /dev/null

View file

@ -1,15 +1,5 @@
#!/bin/bash
echo '### Test of #! with file as input'
cat >/tmp/shebang <<EOF
#!/usr/local/bin/parallel -Yrk echo
A
B
C
EOF
chmod 755 /tmp/shebang
/tmp/shebang
echo '### Test of #! --shebang'
cat >/tmp/shebang <<EOF
#!/usr/local/bin/parallel --shebang -rk echo
@ -32,7 +22,7 @@ chmod 755 /tmp/shebang
echo '### Test of #! with 2 files as input'
cat >/tmp/shebang <<EOF
#!/usr/local/bin/parallel -Yrk --xapply -a /tmp/123 echo
#!/usr/local/bin/parallel --shebang -rk --xapply -a /tmp/123 echo
A
B
C

View file

@ -7,15 +7,15 @@ SERVER2=parallel@parallel-server2
echo $SERVER2 >~/.parallel/sshloginfile
echo '### Test -W newtempdir/newdir/tmp/ with space dirs'
echo '### Test --wd newtempdir/newdir/tmp/ with space dirs'
ssh $SERVER2 rm -rf newtempdir
stdout parallel -k -W newtempdir/newdir/tmp/ --basefile 1-col.txt --trc {}.6 -S .. -v echo ">"{}.6 ::: './ ab/c"d/ef g' ' ab/c"d/efg' ./b/bar ./b/foo "./ ab /c' d/ ef\"g" ./2-col.txt './a b/cd / ef/efg'
stdout parallel -k --wd newtempdir/newdir/tmp/ --basefile 1-col.txt --trc {}.6 -S .. -v echo ">"{}.6 ::: './ ab/c"d/ef g' ' ab/c"d/efg' ./b/bar ./b/foo "./ ab /c' d/ ef\"g" ./2-col.txt './a b/cd / ef/efg'
# A few rmdir errors are OK as we have multiple files in the same dirs
find . -name '*.6'
echo '### Test -W /tmp/newtempdir/newdir/tmp/ with space dirs'
echo '### Test --wd /tmp/newtempdir/newdir/tmp/ with space dirs'
ssh $SERVER2 rm -rf /tmp/newtempdir
stdout parallel -k -W /tmp/newtempdir/newdir/tmp/ --basefile 1-col.txt --trc {}.7 -S .. -v echo ">"{}.7 ::: './ ab/c"d/ef g' ' ab/c"d/efg' ./b/bar ./b/foo "./ ab /c' d/ ef\"g" ./2-col.txt './a b/cd / ef/efg'
stdout parallel -k --wd /tmp/newtempdir/newdir/tmp/ --basefile 1-col.txt --trc {}.7 -S .. -v echo ">"{}.7 ::: './ ab/c"d/ef g' ' ab/c"d/efg' ./b/bar ./b/foo "./ ab /c' d/ ef\"g" ./2-col.txt './a b/cd / ef/efg'
# A few rmdir errors are OK as we have multiple files in the same dirs
find . -name '*.7'
@ -23,21 +23,21 @@ echo '### Test --workdir ...'
parallel -k --workdir ... --basefile 1-col.txt --trc {}.1 -S .. echo ">"{}.1 ::: 2-col.txt
find . -name '*.1'
echo '### Test -W ...'
parallel -k -W ... --basefile 1-col.txt --trc {}.2 -S .. -v echo ">"{}.2 ::: 2-col.txt
echo '### Test --wd ...'
parallel -k --wd ... --basefile 1-col.txt --trc {}.2 -S .. -v echo ">"{}.2 ::: 2-col.txt
find . -name '*.2'
echo '### Test -W ... with space dirs'
stdout parallel -k -W ... --basefile 1-col.txt --trc {}.3 -S .. -v echo ">"{}.3 ::: './ ab/c"d/ef g' ' ab/c"d/efg' ./b/bar ./b/foo "./ ab /c' d/ ef\"g" ./2-col.txt './a b/cd / ef/efg'
echo '### Test --wd ... with space dirs'
stdout parallel -k --wd ... --basefile 1-col.txt --trc {}.3 -S .. -v echo ">"{}.3 ::: './ ab/c"d/ef g' ' ab/c"d/efg' ./b/bar ./b/foo "./ ab /c' d/ ef\"g" ./2-col.txt './a b/cd / ef/efg'
# A few rmdir errors are OK as we have multiple files in the same dirs
find . -name '*.3'
echo '### Test -W tmpdir'
parallel -k -W tmpdir --basefile 1-col.txt --trc {}.4 -S .. -v echo ">"{}.4 ::: 2-col.txt
echo '### Test --wd tmpdir'
parallel -k --wd tmpdir --basefile 1-col.txt --trc {}.4 -S .. -v echo ">"{}.4 ::: 2-col.txt
find . -name '*.4'
echo '### Test -W /tmp/ with space dirs'
stdout parallel -k -W /tmp/ --basefile 1-col.txt --trc {}.5 -S .. -v echo ">"{}.5 ::: './ ab/c"d/ef g' ' ab/c"d/efg' ./b/bar ./b/foo "./ ab /c' d/ ef\"g" ./2-col.txt './a b/cd / ef/efg'
echo '### Test --wd /tmp/ with space dirs'
stdout parallel -k --wd /tmp/ --basefile 1-col.txt --trc {}.5 -S .. -v echo ">"{}.5 ::: './ ab/c"d/ef g' ' ab/c"d/efg' ./b/bar ./b/foo "./ ab /c' d/ ef\"g" ./2-col.txt './a b/cd / ef/efg'
# A few rmdir errors are OK as we have multiple files in the same dirs
find . -name '*.5'

View file

@ -0,0 +1,3 @@
### Test niceload exit code
3 eq 3
0 eq 0

View file

@ -1,7 +1,3 @@
### Test of #! with file as input
A
B
C
### Test of #! --shebang
A
B

View file

@ -1,4 +1,4 @@
### Test -W newtempdir/newdir/tmp/ with space dirs
### Test --wd newtempdir/newdir/tmp/ with space dirs
echo >./\ ab/c\"d/ef\ g.6
echo >\ ab/c\"d/efg.6
echo >./b/bar.6
@ -13,7 +13,7 @@ echo >./a\ b/cd\ /\ ef/efg.6
./ ab /c' d/ ef"g.6
./a b/cd / ef/efg.6
./2-col.txt.6
### Test -W /tmp/newtempdir/newdir/tmp/ with space dirs
### Test --wd /tmp/newtempdir/newdir/tmp/ with space dirs
echo >./\ ab/c\"d/ef\ g.7
echo >\ ab/c\"d/efg.7
echo >./b/bar.7
@ -30,10 +30,10 @@ echo >./a\ b/cd\ /\ ef/efg.7
./a b/cd / ef/efg.7
### Test --workdir ...
./2-col.txt.1
### Test -W ...
### Test --wd ...
echo >2-col.txt.2
./2-col.txt.2
### Test -W ... with space dirs
### Test --wd ... with space dirs
echo >./\ ab/c\"d/ef\ g.3
echo >\ ab/c\"d/efg.3
echo >./b/bar.3
@ -48,10 +48,10 @@ echo >./a\ b/cd\ /\ ef/efg.3
./ ab /c' d/ ef"g.3
./2-col.txt.3
./a b/cd / ef/efg.3
### Test -W tmpdir
### Test --wd tmpdir
echo >2-col.txt.4
./2-col.txt.4
### Test -W /tmp/ with space dirs
### Test --wd /tmp/ with space dirs
echo >./\ ab/c\"d/ef\ g.5
echo >\ ab/c\"d/efg.5
echo >./b/bar.5