mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-12-22 20:57:53 +00:00
Process limit detected. Passes unittest
This commit is contained in:
parent
8202ef3a11
commit
de39f81033
40
parallel
40
parallel
|
@ -521,6 +521,7 @@ sub min_of_args_and_processes {
|
|||
my $next_arg;
|
||||
my $max_system_proc_reached=0;
|
||||
my $time = time;
|
||||
DoNotReap();
|
||||
do {
|
||||
$min_of_args_and_processes++;
|
||||
$next_arg = get_next_arg();
|
||||
|
@ -528,24 +529,33 @@ sub min_of_args_and_processes {
|
|||
push(@args, $next_arg);
|
||||
}
|
||||
$min_of_args_and_processes % 10 or $time=time;
|
||||
# if($child = fork()) {
|
||||
# push (@children,$child);
|
||||
# } elsif(defined $child) {
|
||||
# sleep 1000000;
|
||||
# } else {
|
||||
# $max_system_proc_reached = 1;
|
||||
# }
|
||||
# debug("Time to fork ten procs ", time-$time, " process ", $min_of_args_and_processes);
|
||||
# if(time-$time > 1) {
|
||||
# # It took more than 1 second to fork ten processes. We should stop forking.
|
||||
# # Let us give the system a little slack
|
||||
# $min_of_args_and_processes = int ($min_of_args_and_processes * 0.9)+1;
|
||||
# $max_system_proc_reached = 1;
|
||||
# }
|
||||
if($child = fork()) {
|
||||
push (@children,$child);
|
||||
} elsif(defined $child) {
|
||||
# The child needs to take one process.
|
||||
# It will be killed later
|
||||
sleep 100000;
|
||||
exit;
|
||||
} else {
|
||||
$max_system_proc_reached = 1;
|
||||
}
|
||||
debug("Time to fork ten procs ", time-$time, " process ", $min_of_args_and_processes);
|
||||
if(time-$time > 1) {
|
||||
# It took more than 1 second to fork ten processes. We should stop forking.
|
||||
# Let us give the system a little slack
|
||||
debug("\nLimiting processes to: $min_of_args_and_processes-10%=".
|
||||
(int ($min_of_args_and_processes * 0.9)+1)."\n");
|
||||
$min_of_args_and_processes = int ($min_of_args_and_processes * 0.9)+1;
|
||||
$max_system_proc_reached = 1;
|
||||
}
|
||||
} while($min_of_args_and_processes <= $processes
|
||||
and defined $next_arg
|
||||
and not $max_system_proc_reached);
|
||||
# kill 9, @children;
|
||||
for $pid (@children) {
|
||||
kill 15, $pid;
|
||||
waitpid($pid,0);
|
||||
}
|
||||
wait();
|
||||
unget_arg(@args);
|
||||
return $min_of_args_and_processes;
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@
|
|||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "PARALLEL 1"
|
||||
.TH PARALLEL 1 "2009-02-17" "perl v5.10.0" "User Contributed Perl Documentation"
|
||||
.TH PARALLEL 1 "2009-02-18" "perl v5.10.0" "User Contributed Perl Documentation"
|
||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
Force outside the file handle limit
|
||||
Start
|
||||
end
|
||||
|
|
2
unittest/actual-results/test10
Normal file
2
unittest/actual-results/test10
Normal file
|
@ -0,0 +1,2 @@
|
|||
33bf8b2986551515cdaff5e860618098 -
|
||||
960bedf6398273937e314fb49c7b3ffa -
|
|
@ -3,6 +3,6 @@
|
|||
echo Force outside the file handle limit
|
||||
# 2009-02-17 Gave fork error
|
||||
(echo echo Start;
|
||||
seq 1 100000 | perl -pe 's/^/true /';
|
||||
seq 1 20000 | perl -pe 's/^/true /';
|
||||
echo echo end) | parallel -uj 0
|
||||
|
||||
|
|
6
unittest/tests-to-run/test10.sh
Normal file
6
unittest/tests-to-run/test10.sh
Normal file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This causes problems if we kill child processes
|
||||
|
||||
seq 1 40 | parallel -j 0 seq 1 10 | sort |md5sum
|
||||
seq 1 40 | parallel -j 0 seq 1 10 '| parallel -j 3 echo' | sort |md5sum
|
|
@ -1,2 +1,3 @@
|
|||
Force outside the file handle limit
|
||||
Start
|
||||
end
|
||||
|
|
2
unittest/wanted-results/test10
Normal file
2
unittest/wanted-results/test10
Normal file
|
@ -0,0 +1,2 @@
|
|||
33bf8b2986551515cdaff5e860618098 -
|
||||
960bedf6398273937e314fb49c7b3ffa -
|
Loading…
Reference in a new issue