The name says it most. On Linux, this would be easy with strace and possibly lsof or /proc , and it was easy on OSX until truss was removed from OSX Leopard along with basic system calls (afaik).
The obvious approach is to solve this problem using dtrace , but, alas, as far as I understand, dtrace will not do it, because it catches events as they occur - and in my case the lock system call is already running, I would gladly agreed, if this can be solved using dtrace , by the way.
I saw that Xcode Instruments has a monitor that achieves something similar by taking periodic samples of the process stack (not sure which system calls it uses to do this!), Maybe something like this on the command line can be pretty good (so how it will display the stack right up to the library call, which ends the system call). To be useful for my use, this βfetch command-line toolβ would have to find and parse the arguments found on the stack in order to be useful in determining which file descriptor we blocked.
Last: on Linux, you can usually do this as a regular user (in the absence of ptrace_scope tricks). It would be great if the OSX solution did not require root as well.
source share