How to see file handles like with “lsof -l”?

◇◆丶佛笑我妖孽 提交于 2020-01-02 07:08:50

问题


I did the commands (source):

$ exec 3>/tmp/thirdfile
$ exec 4>/tmp/fourthfile
$ echo drib >&3
$ echo drab >&4
$ echo another drib >&3
$ echo another drab >&4
$ exec 3>&-
$ exec 4>&-

How can I see the file handles, something like with lsof -l?


回答1:


I don't understand, why not just use lsof:

lsof -p $$

$$ being a shell variable that holds the shell's process ID

You can also limit to just file descriptors like:

lsof -a -d0-65535 -p $$



回答2:


On Linux, you can do something like ls -l /proc/$$/fd, which will show you what file descriptors are open in your shell.

Of course, substitute $$ with other numbers to inspect other processes (at least, the ones you own).



来源:https://stackoverflow.com/questions/1338877/how-to-see-file-handles-like-with-lsof-l

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!