File descriptors open info

I Reid eonu24 at castle.ed.ac.uk
Fri Mar 1 10:06:19 AEST 1991


In article <487 at bria>:

>In an article, theory.tn.cornell.edu!hurf (Hurf Sheldon) writes:
>>is there a Unix system call (or some other method) for
>>finding out how many file descriptors a process has
>>open?

>Well, the *real* way to do this is to go munging through the kernel's
>process table. :-)

Why go to all this trouble when there is a system call to do it (at
least in BSD... don't know about anywhere else). Here's a bit of code
showing it.

_____________________________________________________________________________
#include <stdio.h>
main () 
{
	int nds,mds,a;
	mds = getdtablemax ();
	nds = getdtablesize ();
	printf ("There are %d descriptors (%d maximum) in use at the moment.\n",mds,nds);
}
_____________________________________________________________________________



More information about the Comp.unix.questions mailing list