diff options
author | Chip Salzenberg <chip@atlantic.net> | 1996-12-05 23:01:25 +1200 |
---|---|---|
committer | Chip Salzenberg <chip@atlantic.net> | 1996-12-06 18:56:00 +1200 |
commit | c927212d2335b5e927e5661a9977d30a65bf74f3 (patch) | |
tree | 99c1f236e65717a38c1e1d49fe763cbe2cbee31b /ext/IO | |
parent | 1bea6b6d9d08dd7041bf33b4409b008096b11e05 (diff) | |
download | perl-c927212d2335b5e927e5661a9977d30a65bf74f3.tar.gz |
Don't call CORE::close in file handle DESTROY method
Diffstat (limited to 'ext/IO')
-rw-r--r-- | ext/IO/lib/IO/Handle.pm | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/ext/IO/lib/IO/Handle.pm b/ext/IO/lib/IO/Handle.pm index 4b0b93cc6f..2e20cfdb66 100644 --- a/ext/IO/lib/IO/Handle.pm +++ b/ext/IO/lib/IO/Handle.pm @@ -1,5 +1,3 @@ -# - package IO::Handle; =head1 NAME @@ -193,11 +191,6 @@ use SelectSaver; require Exporter; @ISA = qw(Exporter); -## -## TEMPORARY workaround as perl expects handles to be <FileHandle> objects -## -@FileHandle::ISA = qw(IO::Handle); - $VERSION = "1.12"; $RCS = sprintf("%s", q$Revision: 1.15 $ =~ /([\d\.]+)/); @@ -269,28 +262,22 @@ sub new_from_fd { my $class = ref($_[0]) || $_[0] || "IO::Handle"; @_ == 3 or croak "usage: new_from_fd $class FD, MODE"; my $fh = gensym; + shift; IO::Handle::fdopen($fh, @_) or return undef; bless $fh, $class; } -sub DESTROY { - my ($fh) = @_; - - # During global object destruction, this function may be called - # on FILEHANDLEs as well as on the GLOBs that contains them. - # Thus the following trickery. If only the CORE file operators - # could deal with FILEHANDLEs, it wouldn't be necessary... +# +# That an IO::Handle is being destroyed does not necessarily mean +# that the associated filehandle should be closed. This is because +# *FOO{FILEHANDLE} may by a synonym for *BAR{FILEHANDLE}. +# +# If this IO::Handle really does have the final reference to the +# given FILEHANDLE, then Perl will close it for us automatically. +# - if ($fh =~ /=FILEHANDLE\(/) { - local *TMP = $fh; - close(TMP) - if defined fileno(TMP); - } - else { - close($fh) - if defined fileno($fh); - } +sub DESTROY { } ################################################ |