Steve Peters via RT wrote:
[stas - Mon Jan 05 15:15:57 2004]:

This is a bug report for perl from [EMAIL PROTECTED],
generated with the help of perlbug 1.34 running under perl v5.8.1.


----------------------------------------------------------------- [Please enter your report here]

Consider the following short program:

# using Symbol to support older perls
use Symbol;
for (1..2) {
    my $dup = Symbol::gensym();
    open $dup, "<&DATA" or die "Can't dup DATA: $!";
    print "DATA: " . tell(DATA) . "\n";
    print "dup : " . tell($dup) . "\n";
    #seek $dup, tell(DATA), 0; # rewind to the beginning
    <$dup>;
}

__DATA__
foo
bar

w/o perlio we get:

DATA: 309
dup : 309
DATA: 318
dup : 318

the DATA fh pointer is correctly moved along with 'dup'
as per dup(2).

w/ perlio we get:

DATA: 309
dup : 309
DATA: 309
dup : 313

the DATA fh pointer is frozen and doesn't get moved to
the same pointer as the 'dup' fh.

as rgs quoted on irc:

<rgs> that's what my dup(2) manpage says
<rgs> "After  successful  return  of dup or dup2, the old
      and new descriptors may be used interchangeably."

and Nicolas has followed up:

<Nicholas> problem (presumably) is that duping by file
      number means that the original file handle has buffered
      data, while the new one does not. so underlying Unix fh
      is not at the same file offset as the return from ftell
      might lead you to think

This is observed with any perl 5.8.x



I wondering if either case you have above is correct.  On Linux, I see
the following...

[EMAIL PROTECTED]:~$ PERLIO=:stdio perl rt_24818.pl
DATA: 279
dup : 287
DATA: 279
dup : 287

I get the same with PERLIO=:stdio as you do, Steve. The w/o perlio test was with perl that had no perlio enabed. Here it is again:

/tmp> env PERLIO=:perlio perl-5.8.6-ithread xxx
DATA: 277
dup : 277
DATA: 277
dup : 281
/tmp> env PERLIO=:stdio perl-5.8.6-ithread xxx
DATA: 277
dup : 285
DATA: 277
dup : 285
/tmp> perl-5.8.6-nouseperlio xxx
DATA: 277
dup : 277
DATA: 285
dup : 285

--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com

Reply via email to