mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-22 05:57:54 +00:00
Fixes bug #34422: parallel -X --eta crashes with div by zero
This commit is contained in:
parent
0cd02204c4
commit
f91661b86b
19
src/parallel
19
src/parallel
|
@ -2236,6 +2236,7 @@ sub compute_number_of_processes {
|
|||
::debug("Wanted procs: $wanted_processes\n");
|
||||
my $system_limit =
|
||||
$self->processes_available_by_system_limit($wanted_processes);
|
||||
$system_limit < 1 and ::die_bug('$system_limit < 1');
|
||||
::debug("Limited to procs: $system_limit\n");
|
||||
return $system_limit;
|
||||
}
|
||||
|
@ -2278,6 +2279,7 @@ sub processes_available_by_system_limit {
|
|||
$max_system_proc_reached and last;
|
||||
my $before_getting_arg = time;
|
||||
if($Global::semaphore) {
|
||||
# Skip
|
||||
} elsif(defined $::opt_retries and $count_jobs_already_read) {
|
||||
# For retries we may need to run all jobs on this sshlogin
|
||||
# so include the already read jobs for this sshlogin
|
||||
|
@ -2287,9 +2289,17 @@ sub processes_available_by_system_limit {
|
|||
# The arguments may have to be re-spread over several jobslots
|
||||
# So pessimistically only read one arg per jobslot
|
||||
# instead of a full commandline
|
||||
$Global::JobQueue->{'commandlinequeue'}->{'arg_queue'}->empty() and last;
|
||||
($arg) = $Global::JobQueue->{'commandlinequeue'}->{'arg_queue'}->get();
|
||||
push(@args, $arg);
|
||||
if($Global::JobQueue->{'commandlinequeue'}->{'arg_queue'}->empty()) {
|
||||
if($Global::JobQueue->empty()) {
|
||||
last;
|
||||
} else {
|
||||
($job) = $Global::JobQueue->get();
|
||||
push(@jobs, $job);
|
||||
}
|
||||
} else {
|
||||
($arg) = $Global::JobQueue->{'commandlinequeue'}->{'arg_queue'}->get();
|
||||
push(@args, $arg);
|
||||
}
|
||||
} else {
|
||||
# If there are no more command lines, then we have a process
|
||||
# per command line, so no need to go further
|
||||
|
@ -2347,6 +2357,9 @@ sub processes_available_by_system_limit {
|
|||
("parallel: Warning: Only enough available processes to run ",
|
||||
$system_limit, " jobs in parallel.\n");
|
||||
}
|
||||
if($Global::JobQueue->empty()) {
|
||||
$system_limit ||= 1;
|
||||
}
|
||||
# Cleanup: Close the files
|
||||
for (values %fh) { close $_ }
|
||||
# Cleanup: Kill the children
|
||||
|
|
|
@ -11,3 +11,6 @@ seq 1 10 | stdout parallel --progress "sleep 1; echo {}" | wc -l
|
|||
|
||||
echo '### Test of --progress with no jobs'
|
||||
stdout parallel --progress "sleep 1; echo {}" < /dev/null
|
||||
|
||||
echo '### bug #34422: parallel -X --eta crashes with div by zero'
|
||||
seq 2 | stdout parallel -X --eta echo
|
||||
|
|
|
@ -20,7 +20,7 @@ echo '### Test --nonall';
|
|||
parallel --nonall -k -S $SSHLOGIN1,$SSHLOGIN2 'hostname' | sort
|
||||
|
||||
echo '### Test --nonall -u';
|
||||
parallel --nonall -S $SSHLOGIN1,$SSHLOGIN2 -u 'hostname|grep -q nlv.pi.dk && sleep 2; hostname;sleep 4;hostname;'
|
||||
parallel --nonall -S $SSHLOGIN1,$SSHLOGIN2 -u 'hostname|grep -q vh1 && sleep 2; hostname;sleep 4;hostname;'
|
||||
|
||||
echo '### Test read sshloginfile from STDIN';
|
||||
echo $SSHLOGIN1 | parallel -S - --nonall hostname;
|
||||
|
|
Loading…
Reference in a new issue