Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^4: STDERR going to string

by philkime (Sexton)
on Oct 11, 2011 at 15:29 UTC ( #930844=note: print w/replies, xml ) Need Help??

in reply to Re^3: STDERR going to string
in thread STDERR going to string

Hmm. On Windows I'm currently using a self-compiled 5.14.1 using the strawberry environment but I see the same with "real" strawberry 5.12.2. It seems that re-opening STDERR on windows decouples perl STDERR and the C library STDERR which I can't quite understand since I assumed that they were both fd=2 and I can redirect them both with 2>somewhere on the command line. It's just that perl doesn't see the C library STDERR as STDERR any more. The actual library is using really basic stdio ( fprint(stderr ... ) which is most certainly fd=2. Can perl and C have "different" STDERRs on windows?

Replies are listed 'Best First'.
Re^5: STDERR going to string
by Anonymous Monk on Oct 11, 2011 at 16:12 UTC

    Can perl and C have "different" STDERRs on windows?

    No. There is only one STDERR on windows and it is always fileno 2. Perl wraps things so that stderr is a variable, but fileno 2 is always the original stderr.

    AFAIK, despite claims to the contrary, there is no way to get it to work on win32.

    If it was possible it would work already :)

      But then, why after redirecting STDERR, fileno(STDERR) is still 2? is it cheating?

      And why the Inline::C does example does not work even when the perlio.h redefines C stderr to point to some variable inside the perl runtime?

        The source of the problem *is* perlIO. Not the underlying Windows CRT calls. With the PerlIO #defines in place, you cannot even do:

        fprintf( stderr, ... );

        Without perl crashing in a heap around your ears.

        However, if in your XS code, you #undef stderr to bypass the ridiculous PerlIO redefinitions, things begin to work. But you also have to defeat all the other pointless PerlIO redefinitions.

        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        The start of some sanity?


        How about you tell me?

        If I were curious I would ask perl5-porters :)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://930844]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2018-02-17 22:02 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (249 votes). Check out past polls.