how to find # of file descriptor in a process

how to find # of file descriptor in a process

Post by RAM VERM » Sun, 11 May 2003 13:37:51



A process is running on unix. I need to monitor how many number of file
descriptor it is using at any time. Is there any command or utility I can
use. I would be happy to write small programs also to do this.

Regards,
Ram

 
 
 

how to find # of file descriptor in a process

Post by Chaitanya Atreya P. » Mon, 12 May 2003 02:21:25


Hello,


>A process is running on unix. I need to monitor how many number of file
>descriptor it is using at any time. Is there any command or utility I can
>use. I would be happy to write small programs also to do this.

>Regards,
>Ram

This reply is not an exact solution to your question, however this
could help you...

*getdtablesize* returns the maximum number of file descriptors that the
calling process can open.
#include <unistd.h>
int getdtablesize(void);

*getdtablehi* returns the index of the largest open descriptor for the
calling process plus one.
#include <unistd.h>
int getdtablehi(void);

Bye,
./Chaitanya Atreya

 
 
 

how to find # of file descriptor in a process

Post by Frank Cusac » Mon, 12 May 2003 11:38:57



Quote:> A process is running on unix. I need to monitor how many number of file
> descriptor it is using at any time. Is there any command or utility I can
> use. I would be happy to write small programs also to do this.

heavyweight: lsof
lightweight: ls /proc/$pid/fd