In my tests with perl 5.8.8 on CentOS 5.2, open with ">&=" is failing as soon as or whenever the file descriptor being opened is 2048 or greater. It appears to be failing in perl because strace does not show failed system calls.

#!/usr/bin/perl -w use strict; my $n = 0; my @fh; $|=1; while($n < 5000) { my $fh; print "open $n\n"; open $fh, ">", "/tmp/$n.tmp" or die "open XXX $!"; push(@fh, $fh); print "dup $n\n"; open YYY, ">&=", $fh or die "open YYY $!"; close YYY; $n++; }
open("/tmp/2044.tmp", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 20 +47 ioctl(2047, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfd86918) = -1 ENOTTY (In +appropriate ioctl for device) _llseek(2047, 0, [0], SEEK_CUR) = 0 fstat64(2047, {st_mode=S_IFREG|0755, st_size=0, ...}) = 0 fcntl64(2047, F_SETFD, FD_CLOEXEC) = 0 brk(0x9a0d000) = 0x9a0d000 write(1, "dup 2044\n", 9dup 2044 ) = 9 ioctl(2047, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfd86928) = -1 ENOTTY (In +appropriate ioctl for device) _llseek(2047, 0, [0], SEEK_CUR) = 0 fstat64(2047, {st_mode=S_IFREG|0755, st_size=0, ...}) = 0 fcntl64(2047, F_SETFD, FD_CLOEXEC) = 0 write(1, "open 2045\n", 10open 2045 ) = 10 open("/tmp/2045.tmp", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 20 +48 ioctl(2048, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfd86918) = -1 ENOTTY (In +appropriate ioctl for device) _llseek(2048, 0, [0], SEEK_CUR) = 0 fstat64(2048, {st_mode=S_IFREG|0755, st_size=0, ...}) = 0 fcntl64(2048, F_SETFD, FD_CLOEXEC) = 0 write(1, "dup 2045\n", 9dup 2045 ) = 9 open("/usr/share/locale/locale.alias", O_RDONLY) = 2049 fstat64(2049, {st_mode=S_IFREG|0644, st_size=2528, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, + 0) = 0xb7d14000 read(2049, "# Locale name alias data base.\n#"..., 4096) = 2528 read(2049, "", 4096) = 0 close(2049) = 0 munmap(0xb7d14000, 4096) = 0 open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = +-1 ENOENT (No such file or directory) open("/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = - +1 ENOENT (No such file or directory) open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENO +ENT (No such file or directory) open("/usr/share/locale/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 +ENOENT (No such file or directory) open("/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 E +NOENT (No such file or directory) open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT + (No such file or directory) write(2, "open YYY Inappropriate ioctl for"..., 63open YYY Inappropria +te ioctl for device at ./test2.pl line 14. ) = 63 close(2048) = 0 close(2047) = 0 close(2046) = 0 close(2045) = 0 close(2044) = 0 close(2043) = 0

In reply to Re: perl bug? illegal seek with dup and many filehandles by ig
in thread perl bug? illegal seek with dup and many filehandles by flipper

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.