Issue
I am developing a C application for linux in which I need the open file lists using process ids. I am traversing /proc/pid/fd
directory for file descriptor. But how can I know file path and file name from file descriptor? Or any other method or api function should I use?
Thanks,
Solution
The manual describes /proc/pid/fd/
as:
This is a subdirectory containing one entry for each file which the process has open, named by its file descriptor, and which is a symbolic link to the actual file.
Therefore, you can call stat
on each entry and retrieve metadata about the file.
Answered By - Kerrek SB