Everything I've seen says to use lsof -p
, but I'm looking for something that doesn't require a fork/exec.
For example on Linux one can simply walk /proc/{pid}/fd
.
The open source lsof command is also useful for providing information about files opened by processes, and files opened under specific user accounts.
The Linux lsof command lists information about files that are open by processes running on the system. The lsof command is an acronym for, “list of open files.” In this article I'll share some lsof command examples.
You can use proc_pidinfo
with the PROC_PIDLISTFDS
option to enumerate the files used by a given process. You can then use proc_pidfdinfo
on each file in turn with the PROC_PIDFDVNODEPATHINFO
option to get its path.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With