• 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: Get PID from Socket Descriptor?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get PID from Socket Descriptor?


  • Subject: Re: Get PID from Socket Descriptor?
  • From: Stephane Sudre <email@hidden>
  • Date: Mon, 9 May 2005 19:06:10 +0200


On 9 mai 05, at 19:01, Quinn wrote:

At 17:15 +0100 9/5/05, Charlie Boisseau wrote:
I'd like to minimize the amount of (slow) shell processes I involve. Any ideas would be gratefully appreciated.

I don't think you'll find a nice solution to this problem. Apple knows about this issue <rdar://problem/2655113>; we need similar functionality to tell you what files are open on a volume when you can't eject it (a traditional Mac OS feature that's sorely missed on Mac OS X). However, we haven't yet got around to implementing the correct solution (an API to get this information from the kernel in an implementation independent fashion).


"lsof"'s approach is definitely not the right one. It works by grovelling around in kernel memory. This is why a) it's slow, and b) it's rev-locked to the kernel implementation (every time we change a structure inside the kernel, we have to rebuild "lsof").

For your needs, exec'ing "lsof" represents a pseudo-API to solve this problem. However, as you've noticed, exec'ing command line tools is not really an API. Moreover, peeling a layer off "lsof" (that is, doing what it does) is not a viable solution because of point b) above.

You could solve this problem by loading code into the kernel, but even that would be pretty ugly (you'd either get binary compatibility

What kind of binary (in)compatibility?


_______________________________________________ Do not post admin requests to the list. They will be ignored. Macnetworkprog mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Get PID from Socket Descriptor?
      • From: Quinn <email@hidden>
References: 
 >Re: Get PID from Socket Descriptor? (From: Charlie Boisseau <email@hidden>)
 >Re: Get PID from Socket Descriptor? (From: Quinn <email@hidden>)

  • Prev by Date: Re: WEP KEY <-> CFDataRef ???
  • Next by Date: Re: Get PID from Socket Descriptor?
  • Previous by thread: Re: Get PID from Socket Descriptor?
  • Next by thread: Re: Get PID from Socket Descriptor?
  • Index(es):
    • Date
    • Thread