Re: given a struct sock, how to find pid of process that owns it?

From: Stephen Hemminger
Date: Wed Sep 03 2003 - 14:10:35 EST


On Wed, 03 Sep 2003 13:17:25 -0400
Chris Friesen <cfriesen@xxxxxxxxxxxxxxxxxx> wrote:

>
> I'm working on a small app similar to netstat that only cares about unix
> sockets.
>
> I can easily walk /proc/net/unix, but to find the owner of the socket I
> need to scan /proc, which gets expensive.
>
> Accordingly, I'd like to extend /proc/net/unix to also dump out the pid
> of the process that owns the socket. The only thing is, I can't seem to
> figure out how to find the pid of the socket owner given a pointer to
> the socket struct.
>

There is a N to 1 relationship, you will end up needing the scan.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/