CyberShot
CyberShot

Reputation: 2335

Unix max file descriptors

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?

Upvotes: 1

Views: 1579

Answers (1)

kabirpong
kabirpong

Reputation: 40

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?

Upvotes: 2

Related Questions