Retrieve filename from file descriptor in C

前端 未结 7 1605
野性不改
野性不改 2020-11-22 12:48

Is it possible to get the filename of a file descriptor (Linux) in C?

7条回答
  •  情深已故
    2020-11-22 13:29

    Before writing this off as impossible I suggest you look at the source code of the lsof command.

    There may be restrictions but lsof seems capable of determining the file descriptor and file name. This information exists in the /proc filesystem so it should be possible to get at from your program.

提交回复
热议问题