[MUD-Dev] Re: Question for the list (Semi-OT)
Oliver Jowett
oliver at jowett.manawatu.planet.co.nz
Sun Aug 16 11:59:47 CEST 1998
On Sat, 15 Aug 1998, Nathan F Yospe wrote:
> What I'm looking for is a way, on a generalized unix platform, to track the
> process that is currently binding a descriptor to a socket, and return that
> process's pid, without su access...
>
> For example, while on the host machine, I'd like to be able to make a call,
> int p_id = get_owner(short portnum); Where I say p_id = get_owner(5000). It
> seems like there should be some way to recover this, but... *shrug*
Without su access could be hairy.
lsof (ftp://vic.cc.purdue.edu/pub/tools/unix/lsof) will do it, but it
needs access to kernel memory on most systems. I think that it can work
entirely from /proc under recent linux kernels, although you need read
access to the appropriate /proc/nnn/* entries.
I suspect the answer is "no" for a generic solution, and "probably no" for
most system-specific solutions.
If you're writing code for the process in question, of course, you could
maintain a database of port information somewhere yourself.
-O
More information about the mud-dev-archive
mailing list