[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::digital_unix

Title:DIGITAL UNIX(FORMERLY KNOWN AS DEC OSF/1)
Notice:Welcome to the Digital UNIX Conference
Moderator:SMURF::DENHAM
Created:Thu Mar 16 1995
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:10068
Total number of notes:35879

6077.0. "Trying to Find Open File Descriptors for a Process" by CSC32::D_JANSEN (Dave Jansen) Mon Jul 01 1996 11:44

T.RTitleUserPersonal
Name
DateLines
6077.1kdbxSMURF::SCOTTMon Jul 01 1996 13:193
6077.2lsofCECMOW::RAIKOTue Jul 02 1996 05:439
6077.3HOW MANY fds are open?TAV02::GLASSYossi Glass, 882-3254Wed Mar 12 1997 11:036
Is there any way for a process to find HOW MANY file descriptors are already
opened by it?

Thx,
Y.
6077.4VAXCPU::michaudJeff Michaud - ObjectBrokerWed Mar 12 1997 11:3311
> Is there any way for a process to find HOW MANY file descriptors are already
> opened by it?

	get the the size of the fd table (such as by using getdtablesize())
	and cycle for( i = 0 ; i < maxfd ; i++) and fstat(2) each one.  If
	you get back -1 and errno equal to EBADF then that fd number is not
	in use, else it is.

	of course if you are using threads then the count you get will
	likely be only an approximation depending on what the other threads
	are doing ....