in reply to Re: STDERR going to string
in thread STDERR going to string
I had something like this too but it doesn't work on Windows. Here is a stripped down example using Inline::C. On non-Windows (cygwin included), it outputs correctly:
|ERROR|
On Windows, it gives:
||
ERROR
which shows you that the STDERR isn't being captured.
use File::Temp qw(tempfile); use Inline C; open my $olderr, '>&STDERR'; # save STDERR my ($fh, $fn) = tempfile(); open STDERR, '>&', $fh; test_err(); open STDERR, '>&', $olderr; # reset STDERR close $fh; open my $e, '<', $fn; my $err = <$e>; print "|$err|\n"; __END__ __C__ void test_err() { (void)fprintf (stderr, "ERROR"); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: STDERR going to string
by salva (Canon) on Oct 11, 2011 at 14:20 UTC | |
by philkime (Beadle) on Oct 11, 2011 at 15:29 UTC | |
by Anonymous Monk on Oct 11, 2011 at 16:12 UTC | |
by salva (Canon) on Oct 12, 2011 at 07:43 UTC | |
by BrowserUk (Patriarch) on Feb 17, 2012 at 07:29 UTC | |
by Anonymous Monk on Oct 12, 2011 at 08:35 UTC |
In Section
Seekers of Perl Wisdom