get number of open files in a process?

Joerg Sonnenberger joerg at britannica.bec.de
Thu Jan 21 16:25:31 UTC 2016


On Thu, Jan 21, 2016 at 11:16:37AM -0500, Diane Bruce wrote:
> On Thu, Jan 21, 2016 at 04:36:36PM +0100, Joerg Sonnenberger wrote:
> > On Thu, Jan 21, 2016 at 01:34:18PM +0000, Batutis, Ed wrote:
> > > I need to determine the number of open files in my process - all types of file handles total - sockets, files, everything.
> > 
> > Use getdtablesize() to get the current largest known fd. If you want,
> > you can afterwards loop and use fcntl with F_GETFD to check if the
> > descriptor is still open.
> 
> Better off using getrlimit(2)

I don't think the current process limit has any direct relation to the
maximal open file descriptor.

Joerg


More information about the freebsd-hackers mailing list