get number of open files in a process?

Batutis, Ed Ed.Batutis at netapp.com
Thu Jan 21 13:35:36 UTC 2016


Hi,

I need to determine the number of open files in my process - all types of file handles total - sockets, files, everything.

Does this work reliably for that purpose?

   int num_open = 0; /* number of open files? */
   kinfo_file *inf =  kinfo_getfile(getpid(), &num_open);
   if ( inf ) {
     free(inf);
   }


Thanks,

=Ed




More information about the freebsd-hackers mailing list