Skip to content

Commit cec82fc

Browse files
authored
Document IO handle closure in traps
Closes #1365
1 parent bd426da commit cec82fc

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

doc/Language/traps.pod6

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,21 @@ handy in various instances.
483483
484484
=head1 Input and Output
485485
486+
=head2 Closing Open File Handles and Pipes
487+
488+
Unlike some other languages, Perl 6 does not use reference counting,
489+
and so B<the file handles are NOT closed when they go out of scope>. You
490+
have to explicitly close them either by using L<close> routine or using the
491+
C<:close> argument several of L<IO::Handle's|/type/IO::Handle> methods accept.
492+
See L«C<IO::Handle.close>|/type/IO::Handle#routine_close» for details.
493+
494+
The same rules apply to L<IO::Handle's|/type/IO::Handle> subclass
495+
L<IO::Pipe>, which is what you operate on when reading from a L<Proc> you get
496+
with routines L<run> and L<shell>.
497+
498+
The caveat applies to L<IO::CatHandle> type as well, though not as severely.
499+
See L«C<IO::CatHandle.close>|/type/IO::CatHandle#method_close» for details.
500+
486501
=head2 IO::Path Stringification
487502
488503
Partly for historical reasons and partly by design, an L<IO::Path> object

0 commit comments

Comments
 (0)