summaryrefslogtreecommitdiff
path: root/lib/SelectSaver.pm
diff options
context:
space:
mode:
authorSpider Boardman <spider@orb.nashua.nh.us>1997-03-29 14:06:37 -0500
committerChip Salzenberg <chip@atlantic.net>1997-03-26 07:04:34 +1200
commit37ec1aec856d9f941c54a4c316fd341b54f94bdf (patch)
tree98080885ef51755d5fd40331bbea2d3c6e62e5f5 /lib/SelectSaver.pm
parent5dad0344e72a654bb2ed9a76760452bdb56c6e6d (diff)
downloadperl-37ec1aec856d9f941c54a4c316fd341b54f94bdf.tar.gz
C<new SelectSaver $fh> doesn't always restore
This is a bug report for perl from spider@Orb.Nashua.NH.US, If you're lucky enough to get a signal (such as ALRM) which is handled with die() while in a SelectSaver->new($fh) call, your previous output filehandle is not restored. It violates the basic rule of 'save and restore' handling, in that it modifies the state it wants to restore I<before> it has ensured that the prior state will be restored. Patch: p5p-msgid: 199703291906.OAA07232@Orb.Nashua.NH.US
Diffstat (limited to 'lib/SelectSaver.pm')
-rw-r--r--lib/SelectSaver.pm6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/SelectSaver.pm b/lib/SelectSaver.pm
index 4c764bedcf..5f569222fc 100644
--- a/lib/SelectSaver.pm
+++ b/lib/SelectSaver.pm
@@ -38,8 +38,10 @@ use Symbol;
sub new {
@_ >= 1 && @_ <= 2 or croak 'usage: new SelectSaver [FILEHANDLE]';
- my $fh = (@_ > 1) ? (select qualify($_[1], caller)) : select;
- bless [$fh], $_[0];
+ my $fh = select;
+ my $self = bless [$fh], $_[0];
+ select qualify($_[1], caller) if @_ > 1;
+ $self;
}
sub DESTROY {