Reputation: 315
I am writing a Mac OS X NKE which places a socket filter. One I receive a socket, I need to get the PID of the socket's owner. I have tried the FIOGETOWN ioctl, but I receive an errno of 102 (Operation not supported on socket). Is there any way to get the owner's PID?
Upvotes: 3
Views: 876
Reputation: 315
I found it! Apparently, when the attach callback of a socket filter executes, you are executing in the context of the process that created the socket. A simple call to proc_selfpid() gives the PID.
Upvotes: 5