Fixed bug #38439: "open files" with --files --pipe blocks after a while.

This commit is contained in:
Ole Tange 2013-03-04 21:50:51 +01:00
parent d5fa05b425
commit 93dd376c69
3 changed files with 32 additions and 8 deletions

View file

@ -1094,7 +1094,7 @@ sub read_args_from_command_line {
# Group of arguments on the command line.
# Put them into a file.
# Create argfile
my ($outfh,$name) = ::tempfile(SUFFIX => ".arg", UNLINK => 1);
my ($outfh,$name) = ::tempfile(SUFFIX => ".arg");
unlink($name);
# Put args into argfile
print $outfh map { $_,$/ } @group;
@ -2429,7 +2429,7 @@ sub swap_activity {
# As the command can take long to run if run remote
# save it to a tmp file before moving it to the correct file
my $file = $self->{'swap_activity_file'};
my ($dummy_fh, $tmpfile) = ::tempfile(SUFFIX => ".swp", UNLINK => 1);
my ($dummy_fh, $tmpfile) = ::tempfile(SUFFIX => ".swp");
qx{ ($swap_activity > $tmpfile; mv $tmpfile $file) & };
}
return $self->{'swap_activity'};
@ -2512,7 +2512,7 @@ sub loadavg {
# As the command can take long to run if run remote
# save it to a tmp file before moving it to the correct file
my $file = $self->{'loadavg_file'};
my ($dummy_fh, $tmpfile) = ::tempfile(SUFFIX => ".loa", UNLINK => 1);
my ($dummy_fh, $tmpfile) = ::tempfile(SUFFIX => ".loa");
qx{ ($uptime > $tmpfile && mv $tmpfile $file) & };
}
return $self->{'loadavg'};
@ -3927,11 +3927,10 @@ sub start {
my ($outfh,$errfh,$name);
# To group we create temporary files for STDOUT and STDERR
# To avoid the cleanup unlink the files immediately (but keep them open)
my $unlink = $opt::files ? 0 : 1;
($outfh, $name) = ::tempfile(SUFFIX => ".par", UNLINK => $unlink);
($outfh, $name) = ::tempfile(SUFFIX => ".par");
$job->set_stdoutfilename($name);
$unlink and unlink $name;
($errfh, $name) = ::tempfile(SUFFIX => ".par", UNLINK => $unlink);
$opt::files or unlink $name;
($errfh, $name) = ::tempfile(SUFFIX => ".par");
unlink $name;
open OUT, '>&', $outfh or ::die_bug("Can't redirect STDOUT: $!");
@ -3967,7 +3966,7 @@ sub start {
# Bug:
# If the command does not read the first char, the temp file
# is not deleted.
my ($dummy_fh, $tmpfile) = ::tempfile(SUFFIX => ".chr", UNLINK => 1);
my ($dummy_fh, $tmpfile) = ::tempfile(SUFFIX => ".chr");
$command = qq{
sh -c 'dd bs=1 count=1 of=$tmpfile 2>/dev/null';
test \! -s "$tmpfile" && rm -f "$tmpfile" && exec true;

View file

@ -141,4 +141,7 @@ echo '### Negative replacement strings'
parallel --colsep ' ' echo '{2} + {4} = {2} + {-1}=' '$(( {2} + {-1} ))' ::: "1 2 3 4"
parallel --colsep ' ' echo '{-3}orrect' ::: "1 c 3 4"
echo 'bug #38439: "open files" with --files --pipe blocks after a while'
ulimit -n 15; yes |head -n 10M | parallel-20120822 --pipe -k echo {#} of 21
EOF

View file

@ -237,3 +237,25 @@ correct
correct
2 + 4 = 2 + 4= 6
correct
bug #38439: "open files" with --files --pipe blocks after a while
1 of 21
2 of 21
3 of 21
4 of 21
5 of 21
6 of 21
7 of 21
8 of 21
9 of 21
10 of 21
11 of 21
12 of 21
13 of 21
14 of 21
15 of 21
16 of 21
17 of 21
18 of 21
19 of 21
20 of 21
21 of 21