Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fast way to check if file is open on OS X

Tags:

file-io

macos

Is there a fast way to check if a file handle is closed from the command line on os x?

lsof works, of course, but is super slow.

like image 397
Ben K. Avatar asked Feb 24 '11 00:02

Ben K.


1 Answers

You´ll probably want to check out the DTrace Family man dtrace.

If you´re only interested on pure "file actions" you should have a look at opensnoop, which builds on DTrace and has been included since Mac OS X 10.6. You can show all file in use by a process (by -p pid or -n name) and watch files with -f /path/to/file .

like image 54
Asmus Avatar answered Oct 23 '22 22:10

Asmus