I can replicate the issue with 5.8.x, but not with 5.10.0. The exact limit seems to be 2048 (try something like for my $max (2035..2050) {...} to verify yourself). A bit of digging in the 5.8.8 sources suggests this might have to do with a constant in perlio.c:
#define PERLIO_MAX_REFCOUNTABLE_FD 2048
which would make PerlIOUnix_dup() fail if fd >= PERLIO_MAX_REFCOUNTABLE_FD:
PerlIO * PerlIOUnix_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param, int fl +ags) { PerlIOUnix *os = PerlIOSelf(o, PerlIOUnix); int fd = os->fd; if (flags & PERLIO_DUP_FD) { fd = PerlLIO_dup(fd); } if (fd >= 0 && fd < PERLIO_MAX_REFCOUNTABLE_FD) { f = PerlIOBase_dup(aTHX_ f, o, param, flags); if (f) { /* If all went well overwrite fd in dup'ed lay with the du +p()'ed fd */ PerlIOUnix_setfd(aTHX_ f, fd, os->oflags); return f; } } return NULL; }
In Perl 5.10.0, the respective number of refcountable file descriptors is dynamically resized as needed...
(In case you really want to know, just modify the value, recompile perl, and try again to test the hypothesis :)
In reply to Re: perl bug? illegal seek with dup and many filehandles (PERLIO_MAX_REFCOUNTABLE_FD)
by almut
in thread perl bug? illegal seek with dup and many filehandles
by flipper
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |