Subject: Re: netstat and PIDs
To: None <current-users@NetBSD.ORG>
From: Christoph Badura <>
List: current-users
Date: 09/12/1996 01:43:00
In <>
vax@linkdead.paranoia.COM (VaX#n8) writes:
>I don't know if it would be possible, but it would be Really Nice if netstat
>had an option to show which PID had a particular connection open.

There's no one-to-one relationship between open files or sockets
(vnodes actually) and open file descriptors of processes.

More then one process can have "a particular connection open."

Several processes can references the same entry in the open file table
which references a given vnode.  Other processes can reference a
different entry in the open file table which references the same

>I imagine the kernel must store this info somewhere since it has
>to deliver packets to said process - I guess via the descriptor table[s].

The kernel doesn't store this information, because it doesn't need it
during normal operation.  The kernel doesn't deliver the packets to a
process.  The packets get "delivered" to a socketbuffer which hangs of
the vnode.  The first process to read from that vnode get's the
requested packets.

Of course, that doesn't prevent someone from hacking in a deep kernel
dive into netstat to grovel the process and file tables and extract
the necessary information.  As someone mentioned, there's a PR that
implements this.
Christoph Badura

You don't need to quote my .signature.  Everyone has seen it by now.
Besides, it doesn't add anything to the current thread.