develooper Front page | perl.perl5.porters | Postings from October 2007

[perl #46749] can't open() more than 256 files on Solaris

Thread Next
Robert Martin-Legène
October 23, 2007 16:39
[perl #46749] can't open() more than 256 files on Solaris
Message ID:
# New Ticket Created by  Robert Martin-Legène 
# Please include the string:  [perl #46749]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is a bug report for perl from,
generated with the help of perlbug 1.34 running under perl v5.8.0.

[Please enter your report here]
Seemingly on Solaris 7 @ sparc, Solaris 9 @ sparc, Solaris 10
@ intel I can't get perl to return file number 256 to me. Truss
shows that up to file descriptor #255 are returned to the script
as it is supposed to, but #256 is immediately closed by perl, and
undef is returned.

open("/dev/null", O_RDONLY)                     = 255
fstat(255, 0x0010F9D8)                          = 0
fcntl(255, F_SETFD, 0x00000001)                 = 0
Just got fileno 255
write(1, " J u s t   g o t   f i l".., 20)      = 20
open("/dev/null", O_RDONLY)                     = 256
close(256)                                      = 0
open("/dev/null", O_RDONLY)                     = 256
close(256)                                      = 0
Perl's open() is b0rken: Too many open files, stopped at ./ line 18.
write(2, " P e r l ' s   o p e n (".., 75)      = 75

$ ulimit -n 1234
$ ./
Just got fileno 252
Just got fileno 253
Just got fileno 254
Just got fileno 255
Perl's open() is b0rken: Too many open files, stopped at ./ line 18.
$ cat
#!/usr/bin/perl -w

use strict;
use warnings;
use IO::File;

my @a;
while (1) {
  my $fh = new IO::File('/dev/null');
  if ($fh) {
    printf "Just got fileno %d\n", $fh->fileno;
    push @a, $fh;
    exit if $fh->fileno > 1029;
  } else {
open HAHA, "/dev/null" or die "Perl's open() is b0rken: $!, stopped";

The extra open, is to make sure the fault is not in IO::File.

.. and it's not an OS issue, because it works in C.

$ cat 256.c
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

main() {
  int fh;
  while (1) {
    fh = open("/dev/null", O_RDONLY);
    if (fh == -1) {
    printf("Just got fileno %d\n", fh);
    if (fh > 1030) exit(0);
robert@thunder (0)$ make 256
gcc     256.c   -o 256
$ ./256|tail -2
Just got fileno 1030
Just got fileno 1031

[Please do not change anything below this line]
Site configuration information for perl v5.8.0:

Configured by haarbo at Sun Jan 19 13:33:31 CET 2003.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
    osname=solaris, osvers=2.9, archname=sun4-solaris
    uname='sunos thunder 5.9 generic_112233-03 sun4u sparc sunw,sun-fire-280r '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=undef usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='gcc', ccflags ='-fno-strict-aliasing',
    ccversion='', gccversion='3.2.1', gccosandvers='solaris2.9'
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=4
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc
    perllibs=-lsocket -lnsl -ldl -lm -lc
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'

Locally applied patches:

@INC for perl v5.8.0:

Environment for perl v5.8.0:
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About