develooper Front page | perl.perl5.porters | Postings from October 2007

IO::Pipe::End DESTROY ? Shouldn't close() be called ?

Thread Next
From:
=?ISO-8859-1?Q?Chadda=EF_Fouch=E9?=
Date:
October 30, 2007 16:53
Subject:
IO::Pipe::End DESTROY ? Shouldn't close() be called ?
Message ID:
e9350eaf0710300833t47dd9646v8ef33fadec3f503c@mail.gmail.com
Hello,
   While the void DESTROY in IO::Handle make sense (as explained in
the comment), IO::Pipe::End::DESTROY should really call close() since
it makes a waitpid(). Is there a reason to avoid this ? It defeats in
part the usefulness of IO::Pipe for me as one of my main motivation to
use objects rather than low-level functions for this kind of system
interaction is to avoid the need for explicit cleaning (which I often
forget).

Just adding :
#####
# avoid zombification
sub DESTROY {
   my $fh = shift;
   $fh->close() if $fh->opened();
}
#####
in the IO::Pipe::End package should avoid this problem.

-- 
Jedaï

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About