in reply to Re^2: Weird STDERR/SIGDIE/Encodings issue
in thread Weird STDERR/SIGDIE/Encodings issue
Concerning the recursion I speculated about the following: You're right that the sig handler is disabled, but the standard die functionality is done anyway. So the error string is printed via STDERR on which you enabled the encoding IO layer with binmode. The following code reproduces the error:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Encode; $SIG{__DIE__} = sub { if (defined $^S && $^S == 0) { for my $s (0..$#_) { dcs($_[$s]); }; } }; sub dcs { print Dumper(\@_); my ($p1, $p2) = @_; my @caller = caller(0); print Dumper(\@caller); print STDERR $caller[1]; print STDERR "me: " . $p1; } sub mysub { die; } binmode STDERR, ":encoding(koi8-r)"; binmode STDOUT, ":encoding(koi8-r)"; mysub();
As soon as you change the line
byprint STDERR $caller[1];
you don't get the hanging behaviour.print STDOUT $caller[1];
UPDATE: If you keep the first version but you insert the follwoing line in the if-clause of your die-handler
you also don't get the hanging behaviour even when printing at STDERR.binmode STDERR, ':raw';
McA
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Weird STDERR/SIGDIE/Encodings issue
by vsespb (Chaplain) on Mar 29, 2013 at 10:30 UTC |