Re: File Descriptors
From: pr0grmr (chetmarty_at_hotmail.com)
Date: 03/04/05
- Next message: vsk: "Re: How to resolve 'Multiple main definitions' problem ?"
- Previous message: David Schwartz: "Re: File Descriptors"
- In reply to: David Schwartz: "Re: File Descriptors"
- Next in thread: Rainer Temme: "Re: File Descriptors"
- Reply: Rainer Temme: "Re: File Descriptors"
- Reply: Chuck Dillon: "Re: File Descriptors"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 04 Mar 2005 05:29:19 GMT
#include <stdio.h>
#include <limits.h>
#include <sys/resource.h>
int main (int argc, char ** argv)
{
int rv = 0;
int i;
char tmp[128];
FILE * fd[512];
struct rlimit mylim;
if (getrlimit(RLIMIT_NOFILE, &mylim) == -1)
perror("getrlimit");
else
{
printf("hardlim: %d softlim: %d\n", (int)mylim.rlim_max,
(int)mylim.rlim_cur);
mylim.rlim_cur = 1024;
if (setrlimit(RLIMIT_NOFILE, &mylim) == -1)
perror("setrlimit");
else if (getrlimit(RLIMIT_NOFILE, &mylim) == -1)
perror("getrlimit");
else
printf("hardlim: %d softlim: %d\n", (int)mylim.rlim_max,
(int)mylim.rlim_cur);
}
for (i = 0; i < 512; i++)
{
sprintf(tmp, "%3d.dat", i);
if ((fd[i] = fopen(tmp, "wb")) == NULL)
{
perror("fileopen");
printf("open files: %d\n", i);
i++; break;
}
}
while(i--)
fclose(fd[i]);
return rv;
}
Program run: cshell prompt
hardlim: 65536 softlim: 256
hardlim: 65536 softlim: 1024
fileopen: Too many open files
open files: 253
compilation:
gcc -Wall -O3 -ansi -o gsl fileopen.c
uname -a
SunOS shark 5.9 Generic_117171-12 sun4u sparc SUNW,Ultra-60
Thanks for the interest ...
"David Schwartz" <davids@webmaster.com> wrote in message
news:<d08mm4$nn7$1@nntp.webmaster.com>...
>
> "pr0grmr" <chetmarty@hotmail.com> wrote in message
> news:w1RVd.509$oO4.30@newsread3.news.pas.earthlink.net...
> > Hello All,
> > I am trying to raise the limit of files (file descriptors) that
> > my
> > process can have open and can't get past the OPEN_MAX value.
> > If I getrlimit and setrlimit via RLIMIT_NOFILE to 1024 then a getrlimit
> > again, it shows a soft limit of 1024, originally 256, but if
> > I continue my program opening files, it stops again at 250. The later 6
> > are for STDOUT, STDERR and the like. Can anyone point me in the
> > direction of raising
>
> Post the shortest complete example program that demonstrates your
> problem. Specify what platform you ran it on as well and precisely how you
> invoked it.
>
> DS
>
>
"David Schwartz" <davids@webmaster.com> wrote in message
news:d08mm4$nn7$1@nntp.webmaster.com...
>
> "pr0grmr" <chetmarty@hotmail.com> wrote in message
> news:w1RVd.509$oO4.30@newsread3.news.pas.earthlink.net...
>> Hello All,
>> I am trying to raise the limit of files (file descriptors) that my
>> process can have open and can't get past the OPEN_MAX value.
>> If I getrlimit and setrlimit via RLIMIT_NOFILE to 1024 then a getrlimit
>> again, it shows a soft limit of 1024, originally 256, but if
>> I continue my program opening files, it stops again at 250. The later 6
>> are for STDOUT, STDERR and the like. Can anyone point me in the direction
>> of raising
>
> Post the shortest complete example program that demonstrates your
> problem. Specify what platform you ran it on as well and precisely how you
> invoked it.
>
> DS
>
>
- Next message: vsk: "Re: How to resolve 'Multiple main definitions' problem ?"
- Previous message: David Schwartz: "Re: File Descriptors"
- In reply to: David Schwartz: "Re: File Descriptors"
- Next in thread: Rainer Temme: "Re: File Descriptors"
- Reply: Rainer Temme: "Re: File Descriptors"
- Reply: Chuck Dillon: "Re: File Descriptors"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|