1

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
5
  • What would cause you to believe that this technique would work to look at anything beyond the per-process limit? Commented Apr 25, 2012 at 5:24
  • 1
    You would have to create multiple processes which run simultaneously. Commented Apr 25, 2012 at 5:24
  • 3
    That 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. Commented 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? Commented Apr 25, 2012 at 5:56
  • why not use just getrlimit() ? Commented Jun 10, 2012 at 1:18

1 Answer 1

2

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?

answered Apr 26, 2012 at 2:53
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.