diff options
author | Audrey Tang <cpan@audreyt.org> | 2002-02-18 03:46:47 +0800 |
---|---|---|
committer | Artur Bergman <sky@nanisky.com> | 2002-02-17 11:36:52 +0000 |
commit | 87582a92947b14e9eada0c156f266b59de2f8406 (patch) | |
tree | 144e2052c87bf49b887b0e6c224edf6317698fbc /util.c | |
parent | f5cee1512fcf6895e1f72eb692b5716509ecd392 (diff) | |
download | perl-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 'util.c')
-rw-r--r-- | util.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -1356,6 +1356,8 @@ Perl_vwarn(pTHX_ const char* pat, va_list *args) CV *cv; SV *msv; STRLEN msglen; + IO *io; + MAGIC *mg; msv = vmess(pat, args); message = SvPV(msv, msglen); @@ -1388,6 +1390,20 @@ Perl_vwarn(pTHX_ const char* pat, va_list *args) return; } } + + /* if STDERR is tied, use 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; + return; + } + { PerlIO *serr = Perl_error_log; |