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

print STDERR $caller[1];
by
print STDOUT $caller[1];
you don't get the hanging behaviour.

UPDATE: If you keep the first version but you insert the follwoing line in the if-clause of your die-handler

binmode STDERR, ':raw';
you also don't get the hanging behaviour even when printing at STDERR.

McA


In reply to Re^3: Weird STDERR/SIGDIE/Encodings issue by McA
in thread Weird STDERR/SIGDIE/Encodings issue by vsespb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.