how to check open file without lsof

2019-03-28 03:59发布

In linux, I use lsof to check the file is opened by which process. I have an android device, but no lsof command. Is it possible to find which process open the specific file ?

I will use it to verify the MediaPlayer hold a fd, but it should be closed.

标签: android lsof
3条回答
贼婆χ
2楼-- · 2019-03-28 04:23

Poor man's lsof is to execute

ls -l  /proc/[process id]/fd

Still, you need to be root.

查看更多
甜甜的少女心
3楼-- · 2019-03-28 04:24

Install busybox, it has a lsof command.

查看更多
ゆ 、 Hurt°
4楼-- · 2019-03-28 04:30

Thanks mike jones and Joqn for the tip with poor man's lsof. I used it in the following on busybox (synology nas) to list the fd directories grouped under each process:

  for p in [0-9]*; do ls -l /proc/$p/fd ;done 
查看更多
登录 后发表回答