Date: Thu, 21 Jan 2016 18:39:44 +0000 From: "Batutis, Ed" <Ed.Batutis@netapp.com> To: Joerg Sonnenberger <joerg@britannica.bec.de>, Diane Bruce <db@db.net> Cc: "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org> Subject: RE: get number of open files in a process? Message-ID: <d26cc2fcea304ea6a89f61c2ec497322@hioexcmbx08-prd.hq.netapp.com> In-Reply-To: <20160121162527.GA11600@britannica.bec.de> References: <ea9f2ab2d4f543c8ad34fdeb082f8c7a@hioexcmbx08-prd.hq.netapp.com> <20160121153636.GA10961@britannica.bec.de> <20160121161637.GA83843@night.db.net> <20160121162527.GA11600@britannica.bec.de>
index | next in thread | previous in thread | raw e-mail
> > > 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. Since I need an open handle count I would have to do 2048 fcntl() calls in my case. I'm afraid this doesn't look like a good idea, since it might happen a lot under certain circumstances. Looking at the source for kinfo_getfile, it seems like using this is not a good idea because, according to a comment in bug 197695: https://www.mail-archive.com/freebsd-bugs@freebsd.org/msg21569.html the function uses a sysctl with KERN_PROC_FILEDESC which "might be slow". This function also does two memory allocations for data I don't need to look at. So, I guess the answer is, for me anyway, that there is no sufficiently efficient way to get the number of open file handles from the system for my user-space application. But, if anyone has any more ideas, I'd be happy to hear them! Thanks, =Edhelp
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?d26cc2fcea304ea6a89f61c2ec497322>
