From owner-freebsd-hackers Wed Jun 19 1:53: 6 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from apache.metrocom.ru (www.metrocom.ru [195.5.128.139]) by hub.freebsd.org (Postfix) with ESMTP id 5FC5637B411 for ; Wed, 19 Jun 2002 01:52:57 -0700 (PDT) Received: from apache.metrocom.ru (apache.metrocom.ru [195.5.128.150]) by apache.metrocom.ru (8.12.3/8.12.3) with ESMTP id g5J8qs42029670; Wed, 19 Jun 2002 12:52:54 +0400 (MSD) Date: Wed, 19 Jun 2002 12:52:54 +0400 (MSD) From: Varshavchick Alexander To: Peter Pentchev Cc: hackers@FreeBSD.ORG Subject: Re: Getting pid of listening process In-Reply-To: <20020619084411.GD369@straylight.oblivion.bg> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Yes, it hangs in either cases, here is exactly how I try running it: lsof -t -nbPli 4tcp:80 If anybody could suggest what source code in lsof is dealing with tcp ports it would save a lot of time browsing through all lsof sources... Alexander Varshavchick, Metrocom Joint Stock Company Phone: (812)118-3322, 118-3115(fax) On Wed, 19 Jun 2002, Peter Pentchev wrote: > Date: Wed, 19 Jun 2002 11:44:12 +0300 > From: Peter Pentchev > To: Varshavchick Alexander > Cc: hackers@FreeBSD.ORG > Subject: Re: Getting pid of listening process > > On Wed, Jun 19, 2002 at 12:40:30PM +0400, Varshavchick Alexander wrote: > > On Wed, 19 Jun 2002, Peter Pentchev wrote: > > > > > Date: Wed, 19 Jun 2002 11:02:33 +0300 > > > From: Peter Pentchev > > > To: Varshavchick Alexander > > > Cc: hackers@FreeBSD.ORG > > > Subject: Re: Getting pid of listening process > > > > > > 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 wrote: > > > > > Hi gurus, > > > > > > > > > > can anybody make a hint as how pid of a process listening on a specified > > > > > 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? > > > > > > > > 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: > > > > > > > > lsof -nPli 4tcp:25 > > > > > > > > Of course, depending on your needs, you may want to drop the -P, -l or > > > > -n options. > > > > > > Hit 'send' too fast; if you are only interested in pid's, take a look at > > > the -t option, too :) > > > > 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 > > -- > 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. > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message