Skip to content

Commit

Permalink
Fix IO::Handle.slurp not closing handle cases
Browse files Browse the repository at this point in the history
Spotted while fixing R#3566.  Note that IO::Path.slurp does *not*
need a :close, as that is implicit in IO::Path.slurp.
  • Loading branch information
lizmat committed Mar 23, 2020
1 parent 42c4c3f commit efab398
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/core.c/Distro.pm6
Expand Up @@ -59,7 +59,8 @@ Rakudo::Internals.REGISTER-DYNAMIC: '$*DISTRO', {

# darwin specific info
if $name eq 'darwin' {
my $lookup := kv2Map(shell("sw_vers", :out, :err).out.slurp,':');
my $lookup :=
kv2Map(shell("sw_vers", :out, :err).out.slurp(:close),':');
$name := $_ with $lookup<ProductName>;
$version := $_ with $lookup<ProductVersion>;
$release := $_ with $lookup<BuildVersion>;
Expand All @@ -74,7 +75,8 @@ Rakudo::Internals.REGISTER-DYNAMIC: '$*DISTRO', {
$desc := $_ with $lookup<PRETTY_NAME>;
}
elsif $name eq 'linux' {
my $lookup := kv2Map(shell(<lsb_release -a>, :out, :err).out.slurp,":");
my $lookup :=
kv2Map(shell(<lsb_release -a>, :out, :err).out.slurp(:close),":");
$auth := $_ with $lookup<<"DISTRIBUTOR ID">>;
$desc := $_ with $lookup<DESCRIPTION>;
$release := $_ with $lookup<RELEASE>;
Expand Down
4 changes: 2 additions & 2 deletions src/core.c/IO/CatHandle.pm6
Expand Up @@ -290,10 +290,10 @@ my class IO::CatHandle is IO::Handle {
nqp::if(
nqp::defined($!active-handle),
([~] gather nqp::stmts( # the [~] takes care of both Str and Blobs
(take $!active-handle.slurp(:$bin)),
(take $!active-handle.slurp(:$bin, :close)),
nqp::while(
nqp::defined(self.next-handle),
take $!active-handle.slurp(:$bin)))),
take $!active-handle.slurp(:$bin, :close)))),
Nil)
}
method slurp-rest (|) {
Expand Down

0 comments on commit efab398

Please sign in to comment.