• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Any way to get the count of open files?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Re: Can I flush the cache for an AFP volume? (From: Quinn <email@hidden>)
 >Re: Can I flush the cache for an AFP volume? (From: James Bucanek <email@hidden>)
 >Any way to get the count of open files? (From: "Trainor, Chris" <email@hidden>)

  • Prev by Date: Any way to get the count of open files?
  • Next by Date: unlinking
  • Previous by thread: Any way to get the count of open files?
  • Next by thread: unlinking
  • Index(es):
    • Date
    • Thread