Hello,
My communication server process tells me it can't open more files. Here is some more information.
System definitions : (were checked with ulimit command)
- Soft limit 1024
- Hard limit 4096
My program tries to open 260 files (argument passed on command line)
#include <stdio.h>
#include <errno.h>
#include <sys/resource.h>
int main(int argc, char *argv[])
{
int i;
int count;
FILE *aFiles[6000];
long lValue;
lValue = sysconf (_SC_OPEN_MAX);
printf("Sysconf returns %ld\n",lValue);
count = atoi(argv[1]);
for (i=0; i< count + 5; i++)
{
aFiles = fopen("files.c","r"
;
if (aFiles == NULL)
printf("Error opening file %d %d \n",i,errno);
}
}
The sysconf tool tells me 1024, but starting from file 253 I receive EMFILES return codes.
Somebody at Sun Support told me to adapt the OPEN_MAX line in the limits.h header file, but this include file is not included in my project, and I cannot believe this is a good solution.
Does anybody have any suggestions ?
Regards,
Luc
My communication server process tells me it can't open more files. Here is some more information.
System definitions : (were checked with ulimit command)
- Soft limit 1024
- Hard limit 4096
My program tries to open 260 files (argument passed on command line)
#include <stdio.h>
#include <errno.h>
#include <sys/resource.h>
int main(int argc, char *argv[])
{
int i;
int count;
FILE *aFiles[6000];
long lValue;
lValue = sysconf (_SC_OPEN_MAX);
printf("Sysconf returns %ld\n",lValue);
count = atoi(argv[1]);
for (i=0; i< count + 5; i++)
{
aFiles = fopen("files.c","r"
if (aFiles == NULL)
printf("Error opening file %d %d \n",i,errno);
}
}
The sysconf tool tells me 1024, but starting from file 253 I receive EMFILES return codes.
Somebody at Sun Support told me to adapt the OPEN_MAX line in the limits.h header file, but this include file is not included in my project, and I cannot believe this is a good solution.
Does anybody have any suggestions ?
Regards,
Luc