ls -l /proc/$PID/fd/
Additionally you can also use the /proc file system to display where the cursor is in those files by outputting the contents of /proc/$PID/fdinfo/$FD
which is handy if you have a long running process but forgot to pipe it into `pv` (or any other long running ingest that lacks a progress UI)(Both tricks are Linux only)
lsof -c [process name]
lsof -p [pid]Not taking anything away from lsof as I do use it myself but I do also think there is also merit in learning the /proc file system too because it helps illuminate some of the not-so-hidden magic behind Linux. Even if you then still find lsof or similar become your preferred utility.
Edit: By monitoring things, I mean like finding how far through a dd is after you have started it already.
ls -al /proc/$PID/fd/ | wc -l
Useful for actually knowing what that specific process has open and is respecting your Max Open Files settings.
I'm looking at you Influx.
https://channel9.msdn.com/Shows/Defrag-Tools/Defrag-Tools-12...
https://mspoweruser.com/microsoft-working-on-sysinternals-fo...
https://channel9.msdn.com/Shows/Defrag-Tools/Defrag-Tools-12...
https://github.com/iovisor/bcc/blob/master/tools/opensnoop_e...
`strace -e trace=file`
I see that you are using ptrace to monitor a process. That is also used by strace. Is there something else your application does that strace does not (In relation to files)?
> Isn't this just a reimplementation of strace -fe trace=creat,open,openat,unlink,unlinkat ./program?
> Yes. Though it aims to be simpler and more user friendly.
This traces file events of a single process. Strace can be coaxed into something similar.
Because strace on Linux still fails with:
strace: ptrace(PTRACE_TRACEME, ...): Operation not permitted
in those cases :(edit: fatrace is system-wide, whereas the current tools monitors a specific process
http://manpages.ubuntu.com/manpages/trusty/man1/fatrace.1.ht...
https://piware.de/2012/02/fatrace-report-system-wide-file-ac...
read(3</proc/filesystems>, "", 1024) = 0
Another interesting new strace option is -k which does a stack dump after each syscall. this can be useful to find out what part of the application, like some obscure lib, does weird system calls in your app.