Computing.Net > Forums > Unix > file handles on unix

file handles on unix

Reply to Message Icon

Original Message
Name: Tricia
Date: October 18, 2000 at 17:45:06 Pacific
Subject: file handles on unix
Comment:

I would like to be able to programmatically determine the number of file handles available on the various flavors of unix. This parameter determines the number of open files you can have in one process at one time.


Report Offensive Message For Removal


Response Number 1
Name: max
Date: November 2, 2000 at 12:02:16 Pacific
Reply: (edit)

The constant NOFILE in defines the maximum number of open files per process.

In the case this constant is not in param.h, type the command :
find /usr/include -name "*.h" -exec grep "NOFILE" {} \; -print

this would tell you in which header to find it. In general, only 20 files can be opened.

This is used by some daemons to close all file descriptors (when they are properly developed). But some of them use the constant _NFILE in instead of NOFILE... which is the maximum number of streams. Since a stream is a file, it depends on what you want to close or open. There is about 100 streams that can be opened. This is under System V.

Some other systems such 4.3BSD give you the getdtablesize() system call in , which returns the number of entries in the file descriptor table for a process (cf richard stevens, unix network programming).


Report Offensive Follow Up For Removal

Response Number 2
Name: max
Date: November 2, 2000 at 12:05:53 Pacific
Reply: (edit)

oooops... didn't print the include files :
NOFILE is in sys/param.h
_NFILE in stdio.h
getdtablesize() in unistd.h

sorry ;)


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: file handles on unix

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 6 Days.
Discuss in The Lounge