Re: Any way to get the count of open files?
Re: Any way to get the count of open files?
- Subject: Re: Any way to get the count of open files?
- From: Quinn <email@hidden>
- Date: Wed, 15 Oct 2008 10:08:09 +0100
At 16:44 -0400 14/10/08, Trainor, Chris wrote:
I can use lsof to get the list of open files for a particular
process from the commandline. Is there a way to do it
programmatically? I did a bunch of searching, but I can't seem to
find a function that will do it.
The most compatible way is to fork/exec "lsof". It has an option
(-F) that causes it to generate machine readable output (see the
"OUTPUT FOR OTHER PROGRAMS" section of <x-man-page://8/lsof>).
In the long term you will be able to do this using <libproc.h>, which
was introduced in 10.5. Right now that API is public but it's very
new and lives on the border of supportability, so it's hard for me to
wholeheartedly recommend it. I expect that these issues will be
resolved in the future and that this will become the standard
solution to this problem.
S+E
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden