I recently wrote a program to figure out the max amount of file descriptors open per process.
It was essentially
int fd = creat("somefile.dat");
int count = 1;
while(1)
{
int s = dup(fd);
if (s == -1)
break;
count++;
}
printf("Max fd: %d", s);
Now how would I apply this same program but to find the the max fd amount system-wide instead of per process?
asked Apr 25, 2012 at 5:22
CyberShot
2,3757 gold badges29 silver badges37 bronze badges
-
What would cause you to believe that this technique would work to look at anything beyond the per-process limit?geekosaur– geekosaur2012年04月25日 05:24:52 +00:00Commented Apr 25, 2012 at 5:24
-
1You would have to create multiple processes which run simultaneously.wallyk– wallyk2012年04月25日 05:24:56 +00:00Commented Apr 25, 2012 at 5:24
-
3That only allows you to find the max no. of processes per process for the user that ran that code. Using that technique to push the system-wide limit could be damaging - you'll prevent legitimate processes from opening files while that "thing" runs. Don't. Use whatever OS-specific tool there is to find it out.Mat– Mat2012年04月25日 05:33:42 +00:00Commented Apr 25, 2012 at 5:33
-
I'm actually running this code on Minix, so it shouldn't be too harmful. I dont know how to change my program to look for a system-wide limit? What does that even mean?CyberShot– CyberShot2012年04月25日 05:56:38 +00:00Commented Apr 25, 2012 at 5:56
-
why not use just getrlimit() ?user823738– user8237382012年06月10日 01:18:10 +00:00Commented Jun 10, 2012 at 1:18
1 Answer 1
I have multiple ideas for solutions to this:
1 - Multiply the maximum # of processes allowed in MINIX by the max FDs per process
- My only concern is that there is some sort of a hard cap that is under or over the # of processes * FD's per process
2 - Create a program that runs the above program multiple times
- Stipulation is that you have to somehow return count to the original program and sum it
- Also, I have no idea how to call other processes from within a program and retrieve a return value from it.
- Additionally, how can you run all the processes simultaneously? and how do you know the MAX # of processes, and how do you know when to stop running processes?
P.S. You must be in my ecs150 class aren't you?
Sign up to request clarification or add additional context in comments.
Comments
lang-c