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

[perl #21780] odd bug with handle dup

Thread Next
From:
James E Keenan via RT
Date:
April 21, 2012 09:02
Subject:
[perl #21780] odd bug with handle dup
Message ID:
rt-3.6.HEAD-4610-1335024142-1071.21780-15-0@perl.org
On Mon Mar 31 18:43:53 2003, belg4mit@mit.edu wrote:
> This is a bug report for perl from belg4mit@mit.edu,
> generated with the help of perlbug 1.34 running under perl v5.8.0.
> 
> 
> -----------------------------------------------------------------
> While playing with code to dup DATA to STDIN I inadvertently came
> up with the following
> 
>   $a = tell(DATA);
>   seek(DATA,$a,0);
>   open(STDIN, "<&DATA");
>   while(<STDIN>){
>     print "STDIN: $_";
>   }
>   __DATA__
>   Foo
>   Bar
>   Quux
> 
> The first two lines would seem to be no-ops. And yet in several
> instances nothing is read without them. Known configs where this
> has failed are this box with the version of perl below as well
> as the following perl -V [all Solaris.] I have also received reports
of failure
> without the first two lines on builds of 5.8 for SCO and RH
> 

On Sat May 10 10:32:12 2003, ni-s wrote:
> Strange how these things go unnoticed for ages then get discovered 
> by several people at nearly same time.
> This is caused by "fact" that DATA handle has been read in order to 
> read the script. So some data is in the buffer. The "dup" process 
> does not copy the buffer.
> 
> Not clear if/how this should be fixed:
>   A. Document it
>   B. Make dup do seek(FH,tell(FH),0)  - but with more error checking.
>   C. Make DATA file handle do the seek/tell thing implicitly.

ni-s is no longer with us to handle this old ticket.

This problem appears to be OS-specific; I could not reproduce it on
Darwin or Debian Linux.  Is there someone -- especially on Solaris --
who can try to reproduce this bug?  How should we approach this?

Thank you very much.
Jim Keenan

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

Thread Next


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