max no of open files with perl on solaris

Ron Campbell rc at ITSS.NERC.AC.UK
Mon Dec 23 08:32:56 GMT 2002

 The following little perl script opens as many files as possible
and then tells you how many it managed to open -

$ cat

$count = 0 ;
while ( $count >= 0  ) {

   $count++ ;
   $FH = "FH" . "$count" ;
   open $$FH , "/dev/null" or  last ;

   print "\n $count File opens\n" ;

Obviously, this is a rewrite of a C program which someone posted last
week. Interesting thing is that, no matter what I try, I cant get
more than 255 open files with perl on Solaris. I tried perl 5.6.1, 5.8
Solaris 2.6, Solaris 9 - makes no difference.

Linux is different - no problem opening 1000 files with the above script
if you use ulimit -n 1000 first. Solaris allows up to 65536 in the
"ulimit -n   "   command but it makes no difference to perl.

I think the problem may be that perl uses "C standard IO" lib -

#include <stdio.h>

 and this has a limit of 256 file descriptors ??

Fix is clear  -   something like following in mailscanner.conf

Max Unscanned Messages Per Scan = 10
Max Unsafe Messages Per Scan = 10

[Original values are 500 and 100].

But it is nice to have an explanation of what is going on - at least I
think it is !!

I have checked by

1) stopping mailscanner
2) sending a couple of thousand messages ( so they end up in the directory. )
3) starting  mailscanner and watching it work thru the backlog with no
messages about "unable to open" files

                         Cheers ...  Ron Campbell

Ron Campbell      Email: rc at    Fax: 01491 692446
IT Solutions & Services, NERC.               Phone: 01491 692346
Maclean Building, Crowmarsh Gifford, Wallingford, Oxon  OX10 8BB

More information about the MailScanner mailing list