Skip to content

Commit 3946062

Browse files
committed
Explicitely close some file handles
1 parent da8d528 commit 3946062

File tree

6 files changed

+9
-0
lines changed

6 files changed

+9
-0
lines changed

lib/App/Yath/Command/runner.pm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,9 @@ sub update_io {
374374
my $msg = "$_[0] at $caller[1] line $caller[2] ($caller2[1] line $caller2[2]).\n";
375375
print $stderr $msg;
376376
print STDERR $msg;
377+
close($out_fh);
378+
close($err_fh);
379+
close($in_fh) if $in_fh;
377380
POSIX::_exit(127);
378381
};
379382

lib/App/Yath/Command/spawn.pm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,12 @@ sub run {
180180
sleep 0.2;
181181
}
182182
}
183+
close($wfh);
183184

184185
$self->clear_sig_handlers();
185186

186187
my $exit = read_line($fh) // die "Could not get exit code";
188+
close($fh);
187189
$exit = parse_exit($exit);
188190
if ($exit->{sig}) {
189191
print STDERR "Terminated with signal: $exit->{sig}.\n";

lib/App/Yath/Tester.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ sub yath {
129129
push @lines => @new;
130130
print map { chomp($_); "DEBUG: > $_\n" } @new if $debug > 1;
131131
}
132+
close($rh);
132133
}
133134
else {
134135
print "DEBUG: Waiting for $pid\n" if $debug;

lib/Test2/Harness/Collector.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ sub process_runner_output {
170170
stream => Test2::Harness::Util::File::Stream->new(name => File::Spec->catfile($auxdir, $path)),
171171
};
172172
}
173+
closedir($dh);
173174

174175
for my $file (sort keys %{$self->{+RUNNER_AUX_HANDLES}}) {
175176
my $data = $self->{+RUNNER_AUX_HANDLES}->{$file};

lib/Test2/Harness/Util.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ sub find_libraries {
318318
next unless -f $path && $path =~ m/\.pm$/;
319319
push @found => [$path, $prefix];
320320
}
321+
closedir($dh);
321322
}
322323

323324
push @bases => $new_base if @$new_base;

scripts/yath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ BEGIN {
3333
if ($no_stat{lc($^O)}) {
3434
opendir(my $dh, $dir) or die "$!";
3535
my $key = join ':' => sort readdir($dh);
36+
closedir($dh);
3637
last if $seen{$key}++;
3738
}
3839
else {

0 commit comments

Comments
 (0)