mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-25 23:47:53 +00:00
parallel: --files/--results --line-buffer fix.
This commit is contained in:
parent
5829f512c1
commit
a4ddcbf8bc
23
src/parallel
23
src/parallel
|
@ -8107,11 +8107,11 @@ sub print {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
::debug("print", "File descriptor $fdno (", $self->fh($fdno,"name"), "):\n");
|
::debug("print", "File descriptor $fdno (", $self->fh($fdno,"name"), "):\n");
|
||||||
if($opt::files) {
|
if($opt::linebuffer) {
|
||||||
$self->files_print($fdno,$in_fh,$out_fd);
|
|
||||||
} elsif($opt::linebuffer) {
|
|
||||||
# Line buffered print out
|
# Line buffered print out
|
||||||
$self->linebuffer_print($fdno,$in_fh,$out_fd);
|
$self->linebuffer_print($fdno,$in_fh,$out_fd);
|
||||||
|
} elsif($opt::files) {
|
||||||
|
$self->files_print($fdno,$in_fh,$out_fd);
|
||||||
} elsif($opt::tag or defined $opt::tagstring) {
|
} elsif($opt::tag or defined $opt::tagstring) {
|
||||||
$self->tag_print($fdno,$in_fh,$out_fd);
|
$self->tag_print($fdno,$in_fh,$out_fd);
|
||||||
} else {
|
} else {
|
||||||
|
@ -8137,7 +8137,6 @@ sub files_print {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($fdno,$in_fh,$out_fd) = @_;
|
my ($fdno,$in_fh,$out_fd) = @_;
|
||||||
|
|
||||||
if($opt::group and defined $self->{'exitstatus'}) {
|
|
||||||
# If the job is dead: close printing fh. Needed for --compress
|
# If the job is dead: close printing fh. Needed for --compress
|
||||||
close $self->fh($fdno,"w");
|
close $self->fh($fdno,"w");
|
||||||
if($? and $opt::compress) {
|
if($? and $opt::compress) {
|
||||||
|
@ -8149,7 +8148,6 @@ sub files_print {
|
||||||
CORE::kill "TERM", $self->fh($fdno,"rpid");
|
CORE::kill "TERM", $self->fh($fdno,"rpid");
|
||||||
}
|
}
|
||||||
close $in_fh;
|
close $in_fh;
|
||||||
}
|
|
||||||
|
|
||||||
if($opt::pipe and $self->virgin()) {
|
if($opt::pipe and $self->virgin()) {
|
||||||
# Nothing was printed to this job:
|
# Nothing was printed to this job:
|
||||||
|
@ -8189,8 +8187,15 @@ sub linebuffer_print {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if($opt::files or $opt::results) {
|
||||||
|
if($fdno == 1 and not $self->fh($fdno,"printed")) {
|
||||||
|
print $out_fd $self->tag(),$self->fh($fdno,"name"),"\n";
|
||||||
|
$self->set_fh($fdno,"printed",1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
# This seek will clear EOF
|
# This seek will clear EOF
|
||||||
seek $in_fh, tell($in_fh), 0;
|
seek $in_fh, tell($in_fh), 0;
|
||||||
|
my $outputlength = 0;
|
||||||
# The read is non-blocking: The $in_fh is set to non-blocking.
|
# The read is non-blocking: The $in_fh is set to non-blocking.
|
||||||
# 32768 --tag = 5.1s
|
# 32768 --tag = 5.1s
|
||||||
# 327680 --tag = 4.4s
|
# 327680 --tag = 4.4s
|
||||||
|
@ -8198,7 +8203,6 @@ sub linebuffer_print {
|
||||||
# 3276800 --tag = 4.3s
|
# 3276800 --tag = 4.3s
|
||||||
# 10240000 --tag = 4.3s
|
# 10240000 --tag = 4.3s
|
||||||
# 32768000 --tag = 4.7s
|
# 32768000 --tag = 4.7s
|
||||||
my $outputlength = 0;
|
|
||||||
while(read($in_fh,substr($$partial,length $$partial),3276800)) {
|
while(read($in_fh,substr($$partial,length $$partial),3276800)) {
|
||||||
# Append to $$partial
|
# Append to $$partial
|
||||||
# Find the last \n or \r
|
# Find the last \n or \r
|
||||||
|
@ -8220,15 +8224,20 @@ sub linebuffer_print {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$self->add_returnsize($outputlength);
|
$self->add_returnsize($outputlength);
|
||||||
|
}
|
||||||
if(defined $self->{'exitstatus'}) {
|
if(defined $self->{'exitstatus'}) {
|
||||||
|
if($opt::files or $opt::results) {
|
||||||
|
$self->add_returnsize(-s $self->fh($fdno,"name"));
|
||||||
|
} else {
|
||||||
# If the job is dead: print the remaining partial line
|
# If the job is dead: print the remaining partial line
|
||||||
# read remaining
|
# read remaining
|
||||||
$self->add_returnsize(length $$partial);
|
$self->add_returnsize(length $$partial);
|
||||||
if($$partial and ($opt::tag or defined $opt::tagstring)) {
|
if(length $$partial and ($opt::tag or defined $opt::tagstring)) {
|
||||||
my $tag = $self->tag();
|
my $tag = $self->tag();
|
||||||
$$partial =~ s/^/$tag/gm;
|
$$partial =~ s/^/$tag/gm;
|
||||||
}
|
}
|
||||||
print $out_fd $$partial;
|
print $out_fd $$partial;
|
||||||
|
}
|
||||||
# Release the memory
|
# Release the memory
|
||||||
undef $$partial;
|
undef $$partial;
|
||||||
if($self->fh($fdno,"rpid") and CORE::kill 0, $self->fh($fdno,"rpid")) {
|
if($self->fh($fdno,"rpid") and CORE::kill 0, $self->fh($fdno,"rpid")) {
|
||||||
|
|
Loading…
Reference in a new issue