From owner-freebsd-hackers@FreeBSD.ORG Wed Dec 8 23:31:07 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6C13A1065670 for ; Wed, 8 Dec 2010 23:31:07 +0000 (UTC) (envelope-from swell.k@gmail.com) Received: from mail-ww0-f42.google.com (mail-ww0-f42.google.com [74.125.82.42]) by mx1.freebsd.org (Postfix) with ESMTP id F0AFA8FC0C for ; Wed, 8 Dec 2010 23:31:06 +0000 (UTC) Received: by wwi17 with SMTP id 17so2785277wwi.1 for ; Wed, 08 Dec 2010 15:31:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:references :date:in-reply-to:message-id:user-agent:mime-version:content-type; bh=rH59qED6vJV6wMVI2+gq2R/yy8VRBhWVBLDYcPqAp9A=; b=fSqoQYb/T0HWc4iymRiykix5aC+OMjByq02qMc/dgfOZTC/s93vktpZjisoAht0aKo Dmoc5eMzYFZSHGiw7B1uBcFhCNL8QFhFWdeko1qmDA/9Ivf9kCRH6BQVF94LhcZTNDB2 vNYb+Rb8/YLC0eH2PT23YNQ449saKqbsTJtIQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=nOpxLOKU8sdsdTJ8kvzw6YT1nDjWLmSyB567asINOFYDyVsQcaRT0ThVcCalvAz7Kx oyHZvmopR8VXve+D8VdtGVegdcfL3FOtaToWidG0zq2/BL/Pn3QJBxfq0dtcE+ePUJgy JeDO0qzEB7A7tJqk+wdqja7T72JaYx5gGJg/8= Received: by 10.216.180.6 with SMTP id i6mr1223008wem.57.1291851065455; Wed, 08 Dec 2010 15:31:05 -0800 (PST) Received: from localhost ([74.3.165.39]) by mx.google.com with ESMTPS id l51sm575763wer.2.2010.12.08.15.31.02 (version=SSLv3 cipher=RC4-MD5); Wed, 08 Dec 2010 15:31:04 -0800 (PST) From: Anonymous To: Bruce Cran References: <4D000448.1050606@telenix.org> <20101208230139.2097c2e8@core.draftnet> Date: Thu, 09 Dec 2010 02:30:05 +0300 In-Reply-To: <20101208230139.2097c2e8@core.draftnet> (Bruce Cran's message of "Wed, 8 Dec 2010 23:01:39 +0000") Message-ID: <86k4jjg7wi.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain Cc: FreeBSD-Hackers , Matthew Fleming , Chuck Robey Subject: Re: getting a list of open files versus PID nos.? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Dec 2010 23:31:07 -0000 Bruce Cran writes: > On Wed, 8 Dec 2010 14:54:57 -0800 > Matthew Fleming wrote: > >> This is what lsof is for. I believe there's one in ports, but I have >> never tried it. > > Is there any advantage to using lsof instead of fstat(1) (fstat -p pid)? procstat(1) can display actual files instead of inodes, e.g. $ procstat -f $(pgrep qemu) PID COMM FD T V FLAGS REF OFFSET PRO NAME 14300 qemu-system-x86_64 cwd v d -------- - - - /home/holo 14300 qemu-system-x86_64 root v d -------- - - - / 14300 qemu-system-x86_64 0 v c rw------ 6 3247126 - /dev/pts/4 14300 qemu-system-x86_64 1 v c rw------ 6 3247126 - /dev/pts/4 14300 qemu-system-x86_64 2 v c rw------ 6 3247126 - /dev/pts/4 14300 qemu-system-x86_64 3 p - rw---n-- 1 0 - - 14300 qemu-system-x86_64 4 p - rw---n-- 1 0 - - 14300 qemu-system-x86_64 5 v r rw--f--- 1 4294967296 - /b/blah.img 14300 qemu-system-x86_64 6 p - rw---n-- 1 0 - - 14300 qemu-system-x86_64 7 p - rw---n-- 1 0 - - 14300 qemu-system-x86_64 8 v r r---f--- 1 283918336 - /b/netbsd-amd64cd-201012060900Z.iso 14300 qemu-system-x86_64 9 s - rw---n-- 1 0 TCP ::.4444 ::.0 14300 qemu-system-x86_64 10 s - rw---n-- 1 0 TCP ::ffff:127.0.0.1.4444 ::ffff:127.0.0.1.26806