in reply to perl bug? illegal seek with dup and many filehandles

It is not an fd-limit issue. Using '>&=' reuses the file descriptor, so it is not increasing the number. You should probably show the whole strace output after the print of 'opened 4000 files'. Your parsing of strace may not be showing the system call actually triggering the die. Also, can you run:
#!/usr/bin/perl -w use strict; use Socket; open OLDOUT, ">&STDOUT"; for (my $i=0;$i<3;$i++) { open STDOUT, ">&", \*OLDOUT or die "reset STDOUT - $!"; my ($in, $out); my $buf; open STDOUT, ">/dev/null" or die "redirect - $!"; socketpair( $in, $out, AF_UNIX, SOCK_STREAM, PF_UNSPEC) or die + $!; printf STDERR "sock is $out file %d\n", fileno ($out); open STDOUT, ">&=", fileno($out) or die ">&= fileno(fd) - $!"; print "test1\n"; open STDOUT, ">&=", $out or die ">&= fd - $!"; print "test2\n"; open STDOUT, ">&", \*OLDOUT or die "reset2 STDOUT - $!"; }
It works OK for me, but I am using a 32-bit 5.8.6.

Replies are listed 'Best First'.
Re^2: perl bug? illegal seek with dup and many filehandles
by flipper (Beadle) on Oct 30, 2008 at 18:55 UTC
    Your test works for me on 32 and 64 bit (I originally found the problem using socketpair() :-). The original script also fails for me using perl, v5.8.8 built for i486-linux-gnu-thread-multi. 32bit strace working with 2000 files:

    and the same process failing with 4000 files: