Process limit detected. Passes unittest

This commit is contained in:
Ole Tange 2009-02-18 05:35:09 +01:00
parent 8202ef3a11
commit de39f81033
8 changed files with 39 additions and 17 deletions

View file

@ -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;
}

View file

@ -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

View file

@ -1,2 +1,3 @@
Force outside the file handle limit
Start
end

View file

@ -0,0 +1,2 @@
33bf8b2986551515cdaff5e860618098 -
960bedf6398273937e314fb49c7b3ffa -

View file

@ -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

View 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

View file

@ -1,2 +1,3 @@
Force outside the file handle limit
Start
end

View file

@ -0,0 +1,2 @@
33bf8b2986551515cdaff5e860618098 -
960bedf6398273937e314fb49c7b3ffa -