Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Jun 2002 11:44:12 +0300
From:      Peter Pentchev <roam@ringlet.net>
To:        Varshavchick Alexander <alex@metrocom.ru>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: Getting pid of listening process
Message-ID:  <20020619084411.GD369@straylight.oblivion.bg>
In-Reply-To: <Pine.GSO.4.21.0206191238580.7233-100000@apache.metrocom.ru>
References:  <20020619080233.GC369@straylight.oblivion.bg> <Pine.GSO.4.21.0206191238580.7233-100000@apache.metrocom.ru>

next in thread | previous in thread | raw e-mail | index | archive | help

--tqI+Z3u+9OQ7kwn0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Jun 19, 2002 at 12:40:30PM +0400, Varshavchick Alexander wrote:
> On Wed, 19 Jun 2002, Peter Pentchev wrote:
>=20
> > Date: Wed, 19 Jun 2002 11:02:33 +0300
> > From: Peter Pentchev <roam@ringlet.net>
> > To: Varshavchick Alexander <alex@metrocom.ru>
> > Cc: hackers@FreeBSD.ORG
> > Subject: Re: Getting pid of listening process
> >=20
> > On Wed, Jun 19, 2002 at 11:01:19AM +0300, Peter Pentchev wrote:
> > > On Wed, Jun 19, 2002 at 11:48:56AM +0400, Varshavchick Alexander wrot=
e:
> > > > Hi gurus,
> > > >=20
> > > > can anybody make a hint as how pid of a process listening on a spec=
ified
> > > > tcp port can be determined? Of cause there are major utilities like=
 lsof
> > > > or sockstat but they gather a lot of extra information and work not=
 too
> > > > fast. What I need ideally would be a small C program which outputs =
pid
> > > > given a port number as a parameter, can anybody help?
> > >=20
> > > Very few things could work faster than lsof(1) with appropriate
> > > command-line options.  I would suggest that you take the time to read
> > > the lsof manual page carefully, then try something like:
> > >=20
> > > lsof -nPli 4tcp:25
> > >=20
> > > Of course, depending on your needs, you may want to drop the -P, -l or
> > > -n options.
> >=20
> > Hit 'send' too fast; if you are only interested in pid's, take a look at
> > the -t option, too :)
>=20
> lsof seems to have problems on the server in question, it takes all cpu
> time and never returns for a long time... Installing the latest lsof
> release didn't help :(

Have you actually tried the -n option?  If it hangs with -n, try -b,
too.

G'luck,
Peter

--=20
Peter Pentchev	roam@ringlet.net	roam@FreeBSD.org
PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
No language can express every thought unambiguously, least of all this one.

--tqI+Z3u+9OQ7kwn0
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQE9EERb7Ri2jRYZRVMRAn2TAKC6TyaXH3GL5ufZ43/g7lej+svKuQCfQFf1
PqripgrKzBHqfz5at2WdAaA=
=Feql
-----END PGP SIGNATURE-----

--tqI+Z3u+9OQ7kwn0--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020619084411.GD369>