ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I tried increasing the maximum no of file descriptors that can be opened per process
which was initially 256 (through ulimit -Sa )
to 512
ulimit -Sa n 512
even after increasing the soft limit to 512
i am unable to have more than 256 file descriptors per process
here is the code that i tried.
Could you please help with this?
Thanks.
Code:
# include <stdio.h>
int main()
{
FILE *fp[300];
int i=0;
while (1)
{
fp[i]=fopen("checkfile.c", "r");
if ( fp[i] == NULL )
{
fprintf(stderr, "now the i value is %d\n", i);
exit (0);
}
fprintf(stderr, "Descriptor: %d done\n", i);
if( i % 10 == 0)
{
fprintf(stderr, "\n\n\n Sleeping \n\n");
sleep (1);
}
i++;
}
return 0;
}
Try with "ulimit -Hn" first, to raise the hard limits, then use "-Sn" See "help ulimit" to see why. To raise them at system level, run "sysctl -a | grep file", then you can increase the proper key with sysctl -w or via the /proc filesystem (which may be /proc/sys/fs/file-max).
Even if you ulimit downwards you can't ulimit yourself back up again, i believe.
i believe that is not that way,
as long as the soft limit dont cross the hard limit then there is no problem
literally the hard limit cannot be crossed ( would be errored out )
moreover, the limit increase that i had tried is only on soft limits but still as a user i can increase the hard limit
if ulimit command is made use to increase or decrease the limits without specifying hard or soft limits it applies to both
Try with "ulimit -Hn" first, to raise the hard limits, then use "-Sn" See "help ulimit" to see why. To raise them at system level, run "sysctl -a | grep file", then you can increase the proper key with sysctl -w or via the /proc filesystem (which may be /proc/sys/fs/file-max).
its my mistake that I hadnot mentioned the distribution
its solaris 5.9
and the equivalient of sysctl i have to run only sysdef
for the file equivalent in solaris is /etc/system. I couldnot find any options in sysdef to change existing limits.
Please correct if I am wrong somewhere.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.