develooper Front page | perl.perl5.porters | Postings from August 2012

[perl #113982] Reopening filehandles can clobber PerlIO layers

From:
Leon Timmermans via RT
Date:
August 7, 2012 04:34
Subject:
[perl #113982] Reopening filehandles can clobber PerlIO layers
Message ID:
rt-3.6.HEAD-11172-1344339263-129.113982-15-0@perl.org
On Wed Jul 04 07:59:23 2012, dmcbride@cpan.org wrote:
> The following code has two surprises.
> 
> a) the layers for STDOUT are different for input vs output.
> b) the layers for STDOUT's output are missing the utf8 layer after
>    the reopening.  (They're missing for $fh, too.)
> 
> (Thanks to #perl for pointing me to PerlIO and that the layers can
> be different, and to leont on #p5p for pointing me to re-opening
>    issues.)

I found this lovely explanation in do_openn (doio.c:597):

    /* Eeek - FIXME !!!
     * If this is a standard handle we discard all the layer stuff
     * and just dup the fd into whatever was on the handle before !
     */

This has been there since 2001 (e99cca91) :-(

Leon

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=113982



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About