summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorAudrey Tang <cpan@audreyt.org>2002-02-18 03:46:47 +0800
committerArtur Bergman <sky@nanisky.com>2002-02-17 11:36:52 +0000
commit87582a92947b14e9eada0c156f266b59de2f8406 (patch)
tree144e2052c87bf49b887b0e6c224edf6317698fbc /pp_ctl.c
parentf5cee1512fcf6895e1f72eb692b5716509ecd392 (diff)
downloadperl-87582a92947b14e9eada0c156f266b59de2f8406.tar.gz
Tied STDERR should catch messages from warn() and die()
Message-ID: <20020217194647.A1410@not.autrijus.org> p4raw-id: //depot/perl@14727
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index 9dbd52522c..14a48c653d 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1224,6 +1224,9 @@ OP *
Perl_die_where(pTHX_ char *message, STRLEN msglen)
{
STRLEN n_a;
+ IO *io;
+ MAGIC *mg;
+
if (PL_in_eval) {
I32 cxix;
register PERL_CONTEXT *cx;
@@ -1303,7 +1306,19 @@ Perl_die_where(pTHX_ char *message, STRLEN msglen)
}
if (!message)
message = SvPVx(ERRSV, msglen);
- {
+
+ /* if STDERR is tied, print to it instead */
+ if (PL_stderrgv && (io = GvIOp(PL_stderrgv))
+ && (mg = SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar))) {
+ dSP; ENTER;
+ PUSHMARK(SP);
+ XPUSHs(SvTIED_obj((SV*)io, mg));
+ XPUSHs(sv_2mortal(newSVpvn(message, msglen)));
+ PUTBACK;
+ call_method("PRINT", G_SCALAR);
+ LEAVE;
+ }
+ else {
#ifdef USE_SFIO
/* SFIO can really mess with your errno */
int e = errno;