You are opening using fopen, and this is limited to 255 file
descriptors[1]. This is a documented design limitation of stdio, and was
an intentional limiation when stdio was created.
What is happening is that the stdio library is calling open, which
returns an fd >255, which it cannot handle, so it silently closes it
again, and IIRC, all data written to the FILE* handle is silently
discarded, but don't quote me on that.
[1] Actually, this may now only be true (at least in recent Solaris
versions) for 32-bit apps. As a quick fix, try re-compiling as a 64-bit
app if possible and re-test. There was talk some time ago about raising
the default stdio fd limit for 64-bit apps, but I've lost track of where
it got to.
Regards,
Brian
Girish wrote:
Hi,
I tried a sample program to see the behaviour of tempnam with increased fds.
#include<iostream>
#include<stdio.h>
#include <unistd.h>
main()
{
int i;
for(i=0;i<50000;i++)
{
char *temporaryFile = tempnam("/home/giripra/", 0 );
FILE *outFile = fopen(temporaryFile,"wb");
std::cout<<"Count: "<<i<<" "<<temporaryFile<<std::endl;
}
}
I found that the fd's will not increase after 256. Why is it so?
I wrapped it to a script and set the ulimit even then I got the same results??
The SCript
set -a
ulimit -Sn 1024
exec "/home/jimmy/Cpp/a.out"
The truss looks very interesting, The file which gets fd 256, seems to get
closed immediately even though there is no close call in the code. However the
other fds i.e from 0 to 254 continues to be open till the program exits. This
is a strange behaviour.See attached file for truss.
------------------------------------------------------------------------
_______________________________________________
opensolaris-discuss mailing list
[email protected]
--
Brian Ruthven
Solaris Revenue Product Engineering
Sun Microsystems UK
Sparc House, Guillemont Park, Camberley, GU17 9QG
_______________________________________________
opensolaris-discuss mailing list
[email protected]