Home » Android » android – how to check open file without lsof

android – how to check open file without lsof

Posted by: admin June 15, 2020 Leave a comment

Questions:

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.

How to&Answers:

Install busybox, it has a lsof command.

Answer:

Poor man’s lsof is to execute

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

Still, you need to be root.

Answer:

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