[comp.unix.wizards] Mapping inet connections to pids

cse@indetech.com (Scott Ellard) (08/04/90)

Is there a UNIX command that relates active internet
connections to the pids which own those connections?

For example, when I run netstat on my SparcStation1,
information about active internet/unix connections
is listed but there doesn't appear to be an option
to relate any of the info to the owner pids.

If there is no such command/option, has anyone written
a program to do this that they might share?

Any suggestions/comments appreciated.
-- 
____*_  C. S. Ellard, Consulting to     {sun,sharkey,pacbell}!indetech!cse
\  / /  Independence Technologies       cse@indetech.com
 \/ /   42705 Lawrence Place            FAX: 415 438-2034
  \/    Fremont, CA 94538               Voice: 415 438-2030

tchrist@convex.COM (Tom Christiansen) (08/04/90)

In article <1990Aug3.225954.25180@indetech.com> cse@indetech.com (Scott Ellard) writes:
>Is there a UNIX command that relates active internet
>connections to the pids which own those connections?

If you have fstat on your system (see the Tahoe tape)
then you can use netstat and fstat in conjunction to 
do this.

--tom
--

    Tom Christiansen                       {uunet,uiucdcs,sun}!convex!tchrist 
    Convex Computer Corporation                            tchrist@convex.COM
		 "EMACS belongs in <sys/errno.h>: Editor too big!"

brnstnd@kramden.acf.nyu.edu (Dan Bernstein) (08/19/90)

In article <1990Aug3.225954.25180@indetech.com> cse@indetech.com (Scott Ellard) writes:
> Is there a UNIX command that relates active internet
> connections to the pids which own those connections?

Not portably; there are no system calls to retrieve such information,
even if it is stored. What do you need the pids for?

> If there is no such command/option, has anyone written
> a program to do this that they might share?

My auth package (c.s.unix volume 22) records the uid and pid that
started any authenticated connection; the uid is available through the
network as per RFC 931, and you can easily modify the daemon to spit out
the pid.

---Dan