getting a list of open files versus PID nos.?
Anonymous
swell.k at gmail.com
Wed Dec 8 23:31:07 UTC 2010
Bruce Cran <bruce at cran.org.uk> writes:
> On Wed, 8 Dec 2010 14:54:57 -0800
> Matthew Fleming <mdf356 at gmail.com> 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
More information about the freebsd-hackers
mailing list